|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\ProxyGenerator\NullObject\MethodGenerator; |
|
6
|
|
|
|
|
7
|
|
|
use Laminas\Code\Reflection\MethodReflection; |
|
8
|
|
|
use PHPUnit\Framework\TestCase; |
|
9
|
|
|
use ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor; |
|
10
|
|
|
use ProxyManagerTestAsset\BaseClass; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Tests for {@see \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor} |
|
14
|
|
|
* |
|
15
|
|
|
* @group Coverage |
|
16
|
|
|
*/ |
|
17
|
|
|
final class NullObjectMethodInterceptorTest extends TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor |
|
21
|
|
|
*/ |
|
22
|
|
|
public function testBodyStructure() : void |
|
23
|
|
|
{ |
|
24
|
|
|
$reflection = new MethodReflection(BaseClass::class, 'publicByReferenceParameterMethod'); |
|
25
|
|
|
$method = NullObjectMethodInterceptor::generateMethod($reflection); |
|
26
|
|
|
|
|
27
|
|
|
self::assertSame('publicByReferenceParameterMethod', $method->getName()); |
|
|
|
|
|
|
28
|
|
|
self::assertCount(2, $method->getParameters()); |
|
|
|
|
|
|
29
|
|
|
self::assertSame('', $method->getBody()); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testBodyStructureWithoutParameters() : void |
|
36
|
|
|
{ |
|
37
|
|
|
$reflectionMethod = new MethodReflection(self::class, 'testBodyStructureWithoutParameters'); |
|
38
|
|
|
|
|
39
|
|
|
$method = NullObjectMethodInterceptor::generateMethod($reflectionMethod); |
|
40
|
|
|
|
|
41
|
|
|
self::assertSame('testBodyStructureWithoutParameters', $method->getName()); |
|
|
|
|
|
|
42
|
|
|
self::assertCount(0, $method->getParameters()); |
|
|
|
|
|
|
43
|
|
|
self::assertSame('', $method->getBody()); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\NullObjectMethodInterceptor |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testBodyStructureWithoutByRefReturn() : void |
|
50
|
|
|
{ |
|
51
|
|
|
$reflectionMethod = new MethodReflection('ProxyManagerTestAsset\BaseClass', 'publicByReferenceMethod'); |
|
52
|
|
|
|
|
53
|
|
|
$method = NullObjectMethodInterceptor::generateMethod($reflectionMethod); |
|
54
|
|
|
|
|
55
|
|
|
self::assertSame('publicByReferenceMethod', $method->getName()); |
|
|
|
|
|
|
56
|
|
|
self::assertCount(0, $method->getParameters()); |
|
|
|
|
|
|
57
|
|
|
self::assertStringMatchesFormat("\$ref%s = null;\nreturn \$ref%s;", $method->getBody()); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.