1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<?php
declare(strict_types=1);
namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator;
use Laminas\Code\Generator\PropertyGenerator;
use Laminas\Code\Reflection\MethodReflection;
use PHPUnit\Framework\TestCase;
use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod;
use ProxyManagerTestAsset\BaseClass;
use function strpos;
/**
* Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod}
*
* @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\InterceptedMethod::generateMethod
* @group Coverage
*/
final class InterceptedMethodTest extends TestCase
{
public function testBodyStructure(): void
{
$valueHolder = $this->createMock(PropertyGenerator::class);
$prefixInterceptors = $this->createMock(PropertyGenerator::class);
$suffixInterceptors = $this->createMock(PropertyGenerator::class);
$valueHolder->method('getName')->willReturn('foo');
$prefixInterceptors->method('getName')->willReturn('pre');
$suffixInterceptors->method('getName')->willReturn('post');
$method = InterceptedMethod::generateMethod(
new MethodReflection(BaseClass::class, 'publicByReferenceParameterMethod'),
$valueHolder,
$prefixInterceptors,
$suffixInterceptors
);
self::assertSame('publicByReferenceParameterMethod', $method->getName());
self::assertCount(2, $method->getParameters());
self::assertGreaterThan(
0,
strpos(
$method->getBody(),
'$returnValue = $this->foo->publicByReferenceParameterMethod($param, $byRefParam);'
)
);
}
}
|