1 | <?php |
||
21 | final class StaticProxyConstructorTest extends TestCase |
||
22 | { |
||
23 | /** @var PropertyGenerator&MockObject */ |
||
24 | private PropertyGenerator $prefixInterceptors; |
||
|
|||
25 | |||
26 | /** @var PropertyGenerator&MockObject */ |
||
27 | private PropertyGenerator $suffixInterceptors; |
||
28 | |||
29 | /** |
||
30 | * {@inheritDoc} |
||
31 | */ |
||
32 | protected function setUp() : void |
||
33 | { |
||
34 | $this->prefixInterceptors = $this->createMock(PropertyGenerator::class); |
||
35 | $this->suffixInterceptors = $this->createMock(PropertyGenerator::class); |
||
36 | |||
37 | $this->prefixInterceptors->method('getName')->willReturn('pre'); |
||
38 | $this->suffixInterceptors->method('getName')->willReturn('post'); |
||
39 | } |
||
40 | |||
41 | public function testSignature() : void |
||
42 | { |
||
43 | $method = new StaticProxyConstructor(new ReflectionClass(ClassWithProtectedProperties::class)); |
||
44 | |||
45 | self::assertSame('staticProxyConstructor', $method->getName()); |
||
46 | self::assertTrue($method->isStatic()); |
||
47 | self::assertSame('public', $method->getVisibility()); |
||
48 | |||
49 | $parameters = $method->getParameters(); |
||
50 | |||
51 | self::assertCount(3, $parameters); |
||
52 | |||
53 | self::assertSame(ClassWithProtectedProperties::class, $parameters['localizedObject']->getType()); |
||
54 | self::assertSame('array', $parameters['prefixInterceptors']->getType()); |
||
55 | self::assertSame('array', $parameters['suffixInterceptors']->getType()); |
||
56 | } |
||
57 | |||
58 | public function testBodyStructure() : void |
||
59 | { |
||
60 | $method = new StaticProxyConstructor(new ReflectionClass(ClassWithPublicProperties::class)); |
||
61 | |||
62 | self::assertSame( |
||
63 | 'static $reflection; |
||
64 | |||
65 | $reflection = $reflection ?? new \ReflectionClass(__CLASS__); |
||
66 | $instance = $reflection->newInstanceWithoutConstructor(); |
||
67 | |||
68 | $instance->bindProxyProperties($localizedObject, $prefixInterceptors, $suffixInterceptors); |
||
69 | |||
70 | return $instance;', |
||
71 | $method->getBody() |
||
72 | ); |
||
73 | } |
||
74 | } |
||
75 |