ProtectedPropertiesMapTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createProperty() 0 6 1
A testExtractsProtectedProperties() 0 15 1
A testSkipsAbstractProtectedMethods() 0 8 1
A testIsStaticPrivate() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\ProxyGenerator\LazyLoadingGhost\PropertyGenerator;
6
7
use Laminas\Code\Generator\PropertyGenerator;
8
use ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\ProtectedPropertiesMap;
9
use ProxyManager\ProxyGenerator\Util\Properties;
10
use ProxyManagerTest\ProxyGenerator\PropertyGenerator\AbstractUniquePropertyNameTest;
11
use ProxyManagerTestAsset\ClassWithAbstractProtectedMethod;
12
use ProxyManagerTestAsset\ClassWithMixedProperties;
13
use ReflectionClass;
14
15
/**
16
 * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\ProtectedPropertiesMap}
17
 *
18
 * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\PropertyGenerator\ProtectedPropertiesMap
19
 * @group Coverage
20
 */
21
final class ProtectedPropertiesMapTest extends AbstractUniquePropertyNameTest
22
{
23
    /**
24
     * {@inheritDoc}
25
     */
26
    protected function createProperty() : PropertyGenerator
27
    {
28
        return new ProtectedPropertiesMap(
29
            Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
30
        );
31
    }
32
33
    public function testExtractsProtectedProperties() : void
34
    {
35
        $map = new ProtectedPropertiesMap(
36
            Properties::fromReflectionClass(new ReflectionClass(ClassWithMixedProperties::class))
37
        );
38
39
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...ectedPropertiesMapTest>.

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...
40
            [
41
                'protectedProperty0' => ClassWithMixedProperties::class,
42
                'protectedProperty1' => ClassWithMixedProperties::class,
43
                'protectedProperty2' => ClassWithMixedProperties::class,
44
            ],
45
            $map->getDefaultValue()->getValue()
46
        );
47
    }
48
49
    public function testSkipsAbstractProtectedMethods() : void
50
    {
51
        $map = new ProtectedPropertiesMap(
52
            Properties::fromReflectionClass(new ReflectionClass(ClassWithAbstractProtectedMethod::class))
53
        );
54
55
        self::assertSame([], $map->getDefaultValue()->getValue());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...ectedPropertiesMapTest>.

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
    }
57
58
    public function testIsStaticPrivate() : void
59
    {
60
        $map = $this->createProperty();
61
62
        self::assertTrue($map->isStatic());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ProxyManagerTest\...ectedPropertiesMapTest>.

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...
63
        self::assertSame(ProtectedPropertiesMap::VISIBILITY_PRIVATE, $map->getVisibility());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...ectedPropertiesMapTest>.

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...
64
    }
65
}
66