Completed
Push — master ( 2f25cf...59cc7f )
by Marco
43:54 queued 18:55
created

testNonReferenceableLocalizedReflectionProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
c 0
b 0
f 0
rs 9.328
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\Exception;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\Exception\UnsupportedProxiedClassException;
9
use ProxyManager\ProxyGenerator\Util\Properties;
10
use ProxyManagerTestAsset\ClassWithMixedTypedProperties;
11
use ProxyManagerTestAsset\ClassWithPrivateProperties;
12
use ReflectionClass;
13
use ReflectionProperty;
14
15
/**
16
 * Tests for {@see \ProxyManager\Exception\UnsupportedProxiedClassException}
17
 *
18
 * @covers \ProxyManager\Exception\UnsupportedProxiedClassException
19
 * @group Coverage
20
 */
21
class UnsupportedProxiedClassExceptionTest extends TestCase
22
{
23
    public function testUnsupportedLocalizedReflectionProperty() : void
24
    {
25
        self::assertSame(
26
            'Provided reflection property "property0" of class "' . ClassWithPrivateProperties::class
27
            . '" is private and cannot be localized in PHP 5.3',
28
            UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty(
29
                new ReflectionProperty(ClassWithPrivateProperties::class, 'property0')
30
            )->getMessage()
31
        );
32
    }
33
34
    public function testNonReferenceableLocalizedReflectionProperties() : void
35
    {
36
        $reflectionClass = new ReflectionClass(ClassWithMixedTypedProperties::class);
37
38
        self::assertSame(
39
            'Cannot create references for following properties of class '
40
            . ClassWithMixedTypedProperties::class
41
            . ': publicBoolPropertyWithoutDefaultValue, publicNullableBoolPropertyWithoutDefaultValue, '
42
            . 'publicIntPropertyWithoutDefaultValue, publicNullableIntPropertyWithoutDefaultValue, '
43
            . 'publicFloatPropertyWithoutDefaultValue, publicNullableFloatPropertyWithoutDefaultValue, '
44
            . 'publicStringPropertyWithoutDefaultValue, publicNullableStringPropertyWithoutDefaultValue, '
45
            . 'publicArrayPropertyWithoutDefaultValue, publicNullableArrayPropertyWithoutDefaultValue, '
46
            . 'publicIterablePropertyWithoutDefaultValue, publicNullableIterablePropertyWithoutDefaultValue, '
47
            . 'publicObjectProperty, publicNullableObjectProperty, publicClassProperty, publicNullableClassProperty, '
48
            . 'protectedBoolPropertyWithoutDefaultValue, protectedNullableBoolPropertyWithoutDefaultValue, '
49
            . 'protectedIntPropertyWithoutDefaultValue, protectedNullableIntPropertyWithoutDefaultValue, '
50
            . 'protectedFloatPropertyWithoutDefaultValue, protectedNullableFloatPropertyWithoutDefaultValue, '
51
            . 'protectedStringPropertyWithoutDefaultValue, protectedNullableStringPropertyWithoutDefaultValue, '
52
            . 'protectedArrayPropertyWithoutDefaultValue, protectedNullableArrayPropertyWithoutDefaultValue, '
53
            . 'protectedIterablePropertyWithoutDefaultValue, protectedNullableIterablePropertyWithoutDefaultValue, '
54
            . 'protectedObjectProperty, protectedNullableObjectProperty, protectedClassProperty, '
55
            . 'protectedNullableClassProperty, privateBoolPropertyWithoutDefaultValue, '
56
            . 'privateNullableBoolPropertyWithoutDefaultValue, privateIntPropertyWithoutDefaultValue, '
57
            . 'privateNullableIntPropertyWithoutDefaultValue, privateFloatPropertyWithoutDefaultValue, '
58
            . 'privateNullableFloatPropertyWithoutDefaultValue, privateStringPropertyWithoutDefaultValue, '
59
            . 'privateNullableStringPropertyWithoutDefaultValue, privateArrayPropertyWithoutDefaultValue, '
60
            . 'privateNullableArrayPropertyWithoutDefaultValue, privateIterablePropertyWithoutDefaultValue, '
61
            . 'privateNullableIterablePropertyWithoutDefaultValue, privateObjectProperty, '
62
            . 'privateNullableObjectProperty, privateClassProperty, privateNullableClassProperty',
63
            UnsupportedProxiedClassException::nonReferenceableLocalizedReflectionProperties(
64
                $reflectionClass,
65
                Properties::fromReflectionClass($reflectionClass)
66
                    ->onlyNonReferenceableProperties()
67
                    ->onlyInstanceProperties()
68
            )->getMessage()
69
        );
70
    }
71
}
72