mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
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:
parent
81990251a2
commit
ef63719d55
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -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 }}
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
55
src/di/tests/Aop/PipelineTest.php
Normal file
55
src/di/tests/Aop/PipelineTest.php
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
22
src/di/tests/Stub/Aspect/NoProcessAspect.php
Normal file
22
src/di/tests/Stub/Aspect/NoProcessAspect.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user