StaticProxyConstructorTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 86
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testBodyStructure() 0 25 1
A testBodyStructureWithoutPublicProperties() 0 20 1
A testBodyStructureWithTypedProperties() 0 36 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\ProxyGenerator\NullObject\MethodGenerator;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\ProxyGenerator\NullObject\MethodGenerator\StaticProxyConstructor;
9
use ProxyManagerTestAsset\ClassWithMixedProperties;
10
use ProxyManagerTestAsset\ClassWithMixedTypedProperties;
11
use ProxyManagerTestAsset\ClassWithPrivateProperties;
12
use ReflectionClass;
13
14
/**
15
 * Tests for {@see \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\StaticProxyConstructor}
16
 *
17
 * @covers \ProxyManager\ProxyGenerator\NullObject\MethodGenerator\StaticProxyConstructor
18
 * @group Coverage
19
 */
20
final class StaticProxyConstructorTest extends TestCase
21
{
22
    public function testBodyStructure() : void
23
    {
24
        $constructor = new StaticProxyConstructor(
25
            new ReflectionClass(ClassWithMixedProperties::class)
26
        );
27
28
        self::assertSame('staticProxyConstructor', $constructor->getName());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
29
        self::assertSame(ClassWithMixedProperties::class, (string) $constructor->getReturnType());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
30
        self::assertTrue($constructor->isStatic());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
31
        self::assertSame('public', $constructor->getVisibility());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
32
        self::assertCount(0, $constructor->getParameters());
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
33
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
34
            'static $reflection;
35
36
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
37
$instance   = $reflection->newInstanceWithoutConstructor();
38
39
$instance->publicProperty0 = null;
40
$instance->publicProperty1 = null;
41
$instance->publicProperty2 = null;
42
43
return $instance;',
44
            $constructor->getBody()
45
        );
46
    }
47
48
    public function testBodyStructureWithoutPublicProperties() : void
49
    {
50
        $constructor = new StaticProxyConstructor(
51
            new ReflectionClass(ClassWithPrivateProperties::class)
52
        );
53
54
        self::assertSame('staticProxyConstructor', $constructor->getName());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
55
        self::assertCount(0, $constructor->getParameters());
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
56
        self::assertSame(ClassWithPrivateProperties::class, (string) $constructor->getReturnType());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
57
        $body = $constructor->getBody();
58
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
59
            'static $reflection;
60
61
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
62
$instance   = $reflection->newInstanceWithoutConstructor();
63
64
return $instance;',
65
            $body
66
        );
67
    }
68
69
    public function testBodyStructureWithTypedProperties() : void
70
    {
71
        $constructor = new StaticProxyConstructor(new ReflectionClass(ClassWithMixedTypedProperties::class));
72
73
        self::assertSame('staticProxyConstructor', $constructor->getName());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
74
        self::assertSame(ClassWithMixedTypedProperties::class, (string) $constructor->getReturnType());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
75
        self::assertTrue($constructor->isStatic());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
76
        self::assertSame('public', $constructor->getVisibility());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
77
        self::assertCount(0, $constructor->getParameters());
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
78
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...icProxyConstructorTest>.

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.

Loading history...
79
            'static $reflection;
80
81
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
82
$instance   = $reflection->newInstanceWithoutConstructor();
83
84
$instance->publicUnTypedProperty = null;
85
$instance->publicUnTypedPropertyWithoutDefaultValue = null;
86
$instance->publicNullableBoolProperty = null;
87
$instance->publicNullableBoolPropertyWithoutDefaultValue = null;
88
$instance->publicNullableIntProperty = null;
89
$instance->publicNullableIntPropertyWithoutDefaultValue = null;
90
$instance->publicNullableFloatProperty = null;
91
$instance->publicNullableFloatPropertyWithoutDefaultValue = null;
92
$instance->publicNullableStringProperty = null;
93
$instance->publicNullableStringPropertyWithoutDefaultValue = null;
94
$instance->publicNullableArrayProperty = null;
95
$instance->publicNullableArrayPropertyWithoutDefaultValue = null;
96
$instance->publicNullableIterableProperty = null;
97
$instance->publicNullableIterablePropertyWithoutDefaultValue = null;
98
$instance->publicNullableObjectProperty = null;
99
$instance->publicNullableClassProperty = null;
100
101
return $instance;',
102
            $constructor->getBody()
103
        );
104
    }
105
}
106