Added test case for checking refcount for aop pipeline. (#3088)

* Added test case for checking refcount for aop pipeline.

* Update
This commit is contained in:
李铭昕 2021-01-08 15:06:04 +08:00 committed by GitHub
parent 81990251a2
commit ef63719d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 3 deletions

View File

@ -11,7 +11,7 @@ jobs:
os: [ubuntu-latest] os: [ubuntu-latest]
php-version: ['7.3', '7.4'] php-version: ['7.3', '7.4']
mysql-version: ['5.7', '8.0'] mysql-version: ['5.7', '8.0']
sw-version: ['4.5.10', '4.6.0-beta'] sw-version: ['4.5.10', '4.6.0']
max-parallel: 4 max-parallel: 4
env: env:
SW_VERSION: ${{ matrix.sw-version }} SW_VERSION: ${{ matrix.sw-version }}

View File

@ -5,9 +5,9 @@ sudo: required
matrix: matrix:
include: include:
- php: 7.3 - php: 7.3
env: SW_VERSION="4.5.9" env: SW_VERSION="4.6.0"
- php: 7.4 - php: 7.4
env: SW_VERSION="4.5.9" env: SW_VERSION="4.6.0"
services: services:
- mysql - mysql

View File

@ -4,6 +4,7 @@
- [#3050](https://github.com/hyperf/hyperf/pull/3050) Fixed extra data saved twice when use `save()` after `increment()` with `extra`. - [#3050](https://github.com/hyperf/hyperf/pull/3050) Fixed extra data saved twice when use `save()` after `increment()` with `extra`.
- [#3082](https://github.com/hyperf/hyperf/pull/3082) Fixed connection has already been bound to another coroutine when used in defer for `hyperf/db`. - [#3082](https://github.com/hyperf/hyperf/pull/3082) Fixed connection has already been bound to another coroutine when used in defer for `hyperf/db`.
- [#3087](https://github.com/hyperf/hyperf/pull/3087) Fixed memory leak when using pipeline sometimes.
## Added ## Added

View File

@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace HyperfTest\Di\Aop;
use Hyperf\Di\Aop\Pipeline;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use HyperfTest\Di\Stub\Aspect\NoProcessAspect;
use Mockery;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
/**
* @internal
* @coversNothing
*/
class PipelineTest extends TestCase
{
protected function tearDown(): void
{
Mockery::close();
}
public function testRefcountForPipelineCarry()
{
$container = Mockery::mock(ContainerInterface::class);
$container->shouldReceive('get')->with(NoProcessAspect::class)->andReturn(new NoProcessAspect());
$pipeline = new Pipeline($container);
$point = new ProceedingJoinPoint(function () {
}, 'Foo', 'call', []);
$res = $pipeline->via('process')->through([
NoProcessAspect::class,
])->send($point)->then(function () {
});
$this->assertTrue($res);
ob_start();
debug_zval_dump($pipeline);
$data = ob_get_clean();
preg_match('/refcount\((\d+)\)/U', $data, $res);
$this->assertEquals(2, $res[1]);
}
}

View File

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace HyperfTest\Di\Stub\Aspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
class NoProcessAspect
{
public function process(ProceedingJoinPoint $proceedingJoinPoint)
{
return true;
}
}