|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\ProxyGenerator\PropertyGenerator; |
|
6
|
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; |
|
9
|
|
|
use ProxyManager\ProxyGenerator\Util\Properties; |
|
10
|
|
|
use ProxyManagerTestAsset\ClassWithMixedProperties; |
|
11
|
|
|
use ProxyManagerTestAsset\ClassWithPublicProperties; |
|
12
|
|
|
use ProxyManagerTestAsset\EmptyClass; |
|
13
|
|
|
use ReflectionClass; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Tests for {@see \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap} |
|
17
|
|
|
* |
|
18
|
|
|
* @covers \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap |
|
19
|
|
|
* @group Coverage |
|
20
|
|
|
*/ |
|
21
|
|
|
final class PublicPropertiesMapTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
public function testEmptyClass() : void |
|
24
|
|
|
{ |
|
25
|
|
|
$publicProperties = new PublicPropertiesMap( |
|
26
|
|
|
Properties::fromReflectionClass(new ReflectionClass(EmptyClass::class)) |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
self::assertIsArray($publicProperties->getDefaultValue()->getValue()); |
|
|
|
|
|
|
30
|
|
|
self::assertEmpty($publicProperties->getDefaultValue()->getValue()); |
|
|
|
|
|
|
31
|
|
|
self::assertTrue($publicProperties->isStatic()); |
|
|
|
|
|
|
32
|
|
|
self::assertSame('private', $publicProperties->getVisibility()); |
|
|
|
|
|
|
33
|
|
|
self::assertTrue($publicProperties->isEmpty()); |
|
|
|
|
|
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testClassWithPublicProperties() : void |
|
37
|
|
|
{ |
|
38
|
|
|
$publicProperties = new PublicPropertiesMap( |
|
39
|
|
|
Properties::fromReflectionClass(new ReflectionClass(ClassWithPublicProperties::class)) |
|
40
|
|
|
); |
|
41
|
|
|
|
|
42
|
|
|
self::assertTrue($publicProperties->isStatic()); |
|
|
|
|
|
|
43
|
|
|
self::assertSame('private', $publicProperties->getVisibility()); |
|
|
|
|
|
|
44
|
|
|
self::assertFalse($publicProperties->isEmpty()); |
|
|
|
|
|
|
45
|
|
|
self::assertSame( |
|
|
|
|
|
|
46
|
|
|
[ |
|
47
|
|
|
'property0' => true, |
|
48
|
|
|
'property1' => true, |
|
49
|
|
|
'property2' => true, |
|
50
|
|
|
'property3' => true, |
|
51
|
|
|
'property4' => true, |
|
52
|
|
|
'property5' => true, |
|
53
|
|
|
'property6' => true, |
|
54
|
|
|
'property7' => true, |
|
55
|
|
|
'property8' => true, |
|
56
|
|
|
'property9' => true, |
|
57
|
|
|
], |
|
58
|
|
|
$publicProperties->getDefaultValue()->getValue() |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testClassWithMixedProperties() : void |
|
63
|
|
|
{ |
|
64
|
|
|
self::assertSame( |
|
|
|
|
|
|
65
|
|
|
[ |
|
66
|
|
|
'publicProperty0' => true, |
|
67
|
|
|
'publicProperty1' => true, |
|
68
|
|
|
'publicProperty2' => true, |
|
69
|
|
|
], |
|
70
|
|
|
(new PublicPropertiesMap( |
|
71
|
|
|
Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class)) |
|
72
|
|
|
))->getDefaultValue()->getValue() |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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.