Completed
Pull Request — master (#271)
by Enrico
10:20
created

RuntimeClassDefintionTest::testConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\PHPSA\Defintion;
4
5
use PHPSA\Compiler\Parameter;
6
use PHPSA\Definition\RuntimeClassDefinition;
7
use ReflectionClass;
8
use Tests\PHPSA\TestCase;
9
10
class RuntimeClassDefintionTest extends TestCase
11
{
12
    const TEST_CLASS_NAME = 'PHPSA\Definition\ClassDefinition';
13
14
    public function testHasMethod()
15
    {
16
        $reflection = new ReflectionClass(self::TEST_CLASS_NAME);
17
        $definition = new RuntimeClassDefinition($reflection);
18
19
        foreach ($reflection->getMethods() as $method) {
20
            static::assertTrue($definition->hasMethod($method->getName()));
0 ignored issues
show
Bug introduced by
Consider using $method->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
21
        }
22
23
        static::assertFalse($definition->hasMethod('XXXXXXXXXXXXXX'));
24
    }
25
26
    public function testHasConst()
27
    {
28
        $reflection = new ReflectionClass('PHPSA\Context');
29
        $definition = new RuntimeClassDefinition($reflection);
30
31
        foreach ($reflection->getConstants() as $constant) {
32
            static::assertTrue($definition->hasConst($constant));
33
        }
34
35
        static::assertFalse($definition->hasConst('XXXXXXXXX'));
36
    }
37
38
    public function testHasConstWithParent()
39
    {
40
        $reflection = new ReflectionClass(Parameter::class);
41
        $definition = new RuntimeClassDefinition($reflection);
42
43
        static::assertFalse($definition->hasConst('BRANCH_ROOT'));
44
        static::assertTrue($definition->hasConst('BRANCH_ROOT', true));
45
    }
46
47
    public function testHasProperty()
48
    {
49
        $reflection = new ReflectionClass('PHPSA\Context');
50
        $definition = new RuntimeClassDefinition($reflection);
51
52
        foreach ($reflection->getProperties() as $property) {
53
            static::assertTrue($definition->hasProperty($property->getName()));
54
        }
55
56
        static::assertFalse($definition->hasProperty('XXXXX'));
57
    }
58
}
59