|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace ApiGen\Parser\Tests\Reflection\ReflectionClass; |
|
4
|
|
|
|
|
5
|
|
|
use ApiGen\Contracts\Parser\Reflection\ConstantReflectionInterface; |
|
6
|
|
|
|
|
7
|
|
|
final class ConstantsTest extends AbstractReflectionClassTestCase |
|
8
|
|
|
{ |
|
9
|
|
|
public function testGetConstants(): void |
|
10
|
|
|
{ |
|
11
|
|
|
$this->assertCount(2, $this->reflectionClass->getConstants()); |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
public function testGetOwnConstants(): void |
|
15
|
|
|
{ |
|
16
|
|
|
$this->assertCount(1, $this->reflectionClass->getOwnConstants()); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function testHasConstant(): void |
|
20
|
|
|
{ |
|
21
|
|
|
$this->assertFalse($this->reflectionClass->hasConstant('NOT_EXISTING')); |
|
22
|
|
|
$this->assertTrue($this->reflectionClass->hasConstant('LEVEL')); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testGetConstant(): void |
|
26
|
|
|
{ |
|
27
|
|
|
$this->assertInstanceOf(ConstantReflectionInterface::class, $this->reflectionClass->getConstant('LEVEL')); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function testHasOwnConstant(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->assertTrue($this->reflectionClass->hasOwnConstant('LEVEL')); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testGetOwnConstant(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->assertInstanceOf( |
|
38
|
|
|
ConstantReflectionInterface::class, |
|
39
|
|
|
$this->reflectionClass->getOwnConstant('LEVEL') |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @expectedException \InvalidArgumentException |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testGetOwnConstantNonExisting(): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->reflectionClass->getOwnConstant('NON_EXISTING'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @expectedException \InvalidArgumentException |
|
53
|
|
|
*/ |
|
54
|
|
|
public function testGetConstantNonExisting(): void |
|
55
|
|
|
{ |
|
56
|
|
|
$this->reflectionClass->getConstant('NON_EXISTING'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testGetInheritedConstants(): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->assertCount(1, $this->reflectionClass->getInheritedConstants()); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|