MagicMethodGeneratorTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGeneratesCorrectByRefReturnValue() 0 7 1
A testGeneratesCorrectByValReturnValue() 0 7 1
A testGeneratesByRefReturnValueWithNonExistingGetMethod() 0 7 1
A testGeneratesByValReturnValueWithNonExistingNonGetMethod() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\Generator;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\Generator\MagicMethodGenerator;
9
use ProxyManagerTestAsset\ClassWithByRefMagicMethods;
10
use ProxyManagerTestAsset\ClassWithMagicMethods;
11
use ProxyManagerTestAsset\EmptyClass;
12
use ReflectionClass;
13
14
/**
15
 * Tests for {@see \ProxyManager\Generator\MagicMethodGenerator}
16
 *
17
 * @group Coverage
18
 * @covers \ProxyManager\Generator\MagicMethodGenerator
19
 */
20
final class MagicMethodGeneratorTest extends TestCase
21
{
22
    public function testGeneratesCorrectByRefReturnValue() : void
23
    {
24
        $reflection  = new ReflectionClass(ClassWithByRefMagicMethods::class);
25
        $magicMethod = new MagicMethodGenerator($reflection, '__get', ['name']);
26
27
        self::assertStringMatchesFormat('%Apublic function & __get(%A', $magicMethod->generate());
0 ignored issues
show
Bug introduced by
The method assertStringMatchesFormat() does not seem to exist on object<ProxyManagerTest\...gicMethodGeneratorTest>.

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...
28
    }
29
30
    public function testGeneratesCorrectByValReturnValue() : void
31
    {
32
        $reflection  = new ReflectionClass(ClassWithMagicMethods::class);
33
        $magicMethod = new MagicMethodGenerator($reflection, '__get', ['name']);
34
35
        self::assertStringMatchesFormat('%Apublic function __get(%A', $magicMethod->generate());
0 ignored issues
show
Bug introduced by
The method assertStringMatchesFormat() does not seem to exist on object<ProxyManagerTest\...gicMethodGeneratorTest>.

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...
36
    }
37
38
    public function testGeneratesByRefReturnValueWithNonExistingGetMethod() : void
39
    {
40
        $reflection  = new ReflectionClass(EmptyClass::class);
41
        $magicMethod = new MagicMethodGenerator($reflection, '__get', ['name']);
42
43
        self::assertStringMatchesFormat('%Apublic function & __get(%A', $magicMethod->generate());
0 ignored issues
show
Bug introduced by
The method assertStringMatchesFormat() does not seem to exist on object<ProxyManagerTest\...gicMethodGeneratorTest>.

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...
44
    }
45
46
    public function testGeneratesByValReturnValueWithNonExistingNonGetMethod() : void
47
    {
48
        $reflection  = new ReflectionClass(EmptyClass::class);
49
        $magicMethod = new MagicMethodGenerator($reflection, '__set', ['name']);
50
51
        self::assertStringMatchesFormat('%Apublic function __set(%A', $magicMethod->generate());
0 ignored issues
show
Bug introduced by
The method assertStringMatchesFormat() does not seem to exist on object<ProxyManagerTest\...gicMethodGeneratorTest>.

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
    }
53
}
54