|
1
|
|
|
<?php |
|
2
|
|
|
namespace Doctrine\Tests\Common\Persistence\Mapping; |
|
3
|
|
|
|
|
4
|
|
|
use Doctrine\Common\Persistence\Mapping\StaticReflectionService; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* @group DCOM-93 |
|
8
|
|
|
*/ |
|
9
|
|
|
class StaticReflectionServiceTest extends \PHPUnit\Framework\TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var StaticReflectionService |
|
13
|
|
|
*/ |
|
14
|
|
|
private $reflectionService; |
|
15
|
|
|
|
|
16
|
|
|
public function setUp() |
|
17
|
|
|
{ |
|
18
|
|
|
$this->reflectionService = new StaticReflectionService(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function testShortname() |
|
22
|
|
|
{ |
|
23
|
|
|
self::assertEquals("StaticReflectionServiceTest", $this->reflectionService->getClassShortName(__CLASS__)); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testClassNamespaceName() |
|
27
|
|
|
{ |
|
28
|
|
|
self::assertEquals('', $this->reflectionService->getClassNamespace(\stdClass::class)); |
|
29
|
|
|
self::assertEquals(__NAMESPACE__, $this->reflectionService->getClassNamespace(__CLASS__)); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testGetParentClasses() |
|
33
|
|
|
{ |
|
34
|
|
|
$classes = $this->reflectionService->getParentClasses(__CLASS__); |
|
35
|
|
|
self::assertTrue(count($classes) == 0, "The test class " . __CLASS__ . " should have no parents according to static reflection."); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testGetReflectionClass() |
|
39
|
|
|
{ |
|
40
|
|
|
$class = $this->reflectionService->getClass(__CLASS__); |
|
|
|
|
|
|
41
|
|
|
self::assertNull($class); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testGetMethods() |
|
45
|
|
|
{ |
|
46
|
|
|
self::assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods")); |
|
47
|
|
|
self::assertTrue($this->reflectionService->hasPublicMethod(__CLASS__, "testGetMethods2")); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testGetAccessibleProperty() |
|
51
|
|
|
{ |
|
52
|
|
|
$reflProp = $this->reflectionService->getAccessibleProperty(__CLASS__, "reflectionService"); |
|
|
|
|
|
|
53
|
|
|
self::assertNull($reflProp); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.