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())); |
|
|
|
|
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
|
|
|
|