-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathRuntimeReflectionServiceTest.php
71 lines (58 loc) · 2.36 KB
/
RuntimeReflectionServiceTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Doctrine\Tests\Common\Persistence\Mapping;
use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\Common\Persistence\Mapping\RuntimeReflectionService;
use Doctrine\Common\Reflection\RuntimePublicReflectionProperty;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use function count;
/**
* @group DCOM-93
*/
class RuntimeReflectionServiceTest extends TestCase
{
/** @var RuntimeReflectionService */
private $reflectionService;
/** @var mixed */
public $unusedPublicProperty;
public function setUp()
{
$this->reflectionService = new RuntimeReflectionService();
}
public function testShortname()
{
self::assertSame('RuntimeReflectionServiceTest', $this->reflectionService->getClassShortName(self::class));
}
public function testClassNamespaceName()
{
self::assertSame('Doctrine\Tests\Common\Persistence\Mapping', $this->reflectionService->getClassNamespace(self::class));
}
public function testGetParentClasses()
{
$classes = $this->reflectionService->getParentClasses(self::class);
self::assertTrue(count($classes) >= 1, 'The test class ' . self::class . ' should have at least one parent.');
}
public function testGetParentClassesForAbsentClass()
{
$this->expectException(MappingException::class);
$this->reflectionService->getParentClasses(__NAMESPACE__ . '\AbsentClass');
}
public function testGetReflectionClass()
{
$class = $this->reflectionService->getClass(self::class);
self::assertInstanceOf('ReflectionClass', $class);
}
public function testGetMethods()
{
self::assertTrue($this->reflectionService->hasPublicMethod(self::class, 'testGetMethods'));
self::assertFalse($this->reflectionService->hasPublicMethod(self::class, 'testGetMethods2'));
}
public function testGetAccessibleProperty()
{
$reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'reflectionService');
self::assertInstanceOf(ReflectionProperty::class, $reflProp);
self::assertInstanceOf(RuntimeReflectionService::class, $reflProp->getValue($this));
$reflProp = $this->reflectionService->getAccessibleProperty(self::class, 'unusedPublicProperty');
self::assertInstanceOf(RuntimePublicReflectionProperty::class, $reflProp);
}
}