MagicWakeupTest::testWillUnsetPrivateProperties()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\ProxyGenerator\AccessInterceptor\MethodGenerator;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup;
9
use ProxyManagerTestAsset\ClassWithMixedProperties;
10
use ProxyManagerTestAsset\EmptyClass;
11
use ProxyManagerTestAsset\ProxyGenerator\LazyLoading\MethodGenerator\ClassWithTwoPublicProperties;
12
use ReflectionClass;
13
14
/**
15
 * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup}
16
 *
17
 * @group Coverage
18
 * @covers \ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup
19
 */
20
final class MagicWakeupTest extends TestCase
21
{
22
    public function testBodyStructure() : void
23
    {
24
        $reflection = new ReflectionClass(
25
            ClassWithTwoPublicProperties::class
26
        );
27
28
        $magicWakeup = new MagicWakeup($reflection);
29
30
        self::assertSame('__wakeup', $magicWakeup->getName());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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::assertCount(0, $magicWakeup->getParameters());
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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::assertSame("unset(\$this->bar, \$this->baz);\n\n", $magicWakeup->getBody());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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
    }
34
35
    public function testBodyStructureWithoutPublicProperties() : void
36
    {
37
        $magicWakeup = new MagicWakeup(new ReflectionClass(EmptyClass::class));
38
39
        self::assertSame('__wakeup', $magicWakeup->getName());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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
        self::assertCount(0, $magicWakeup->getParameters());
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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...
41
        self::assertEmpty($magicWakeup->getBody());
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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...
42
    }
43
44
    /**
45
     * @group 276
46
     */
47
    public function testWillUnsetPrivateProperties() : void
48
    {
49
        $magicWakeup = new MagicWakeup(new ReflectionClass(ClassWithMixedProperties::class));
50
51
        self::assertSame(
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...erator\MagicWakeupTest>.

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...
52
            'unset($this->publicProperty0, $this->publicProperty1, $this->publicProperty2, '
53
            . '$this->protectedProperty0, $this->protectedProperty1, $this->protectedProperty2);
54
55
\Closure::bind(function (\ProxyManagerTestAsset\ClassWithMixedProperties $instance) {
56
    unset($instance->privateProperty0, $instance->privateProperty1, $instance->privateProperty2);
57
}, $this, \'ProxyManagerTestAsset\\\\ClassWithMixedProperties\')->__invoke($this);
58
59
',
60
            $magicWakeup->getBody()
61
        );
62
    }
63
}
64