|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\ORM\Mapping; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
|
6
|
|
|
use Doctrine\ORM\Mapping\AssociationOverride; |
|
7
|
|
|
use Doctrine\ORM\Mapping\Cache; |
|
8
|
|
|
use Doctrine\ORM\Mapping\ChangeTrackingPolicy; |
|
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
10
|
|
|
use Doctrine\ORM\Mapping\InheritanceType; |
|
11
|
|
|
use Doctrine\ORM\Mapping\ManyToMany; |
|
12
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
13
|
|
|
use Doctrine\ORM\Mapping\OneToMany; |
|
14
|
|
|
use Doctrine\ORM\Mapping\OneToOne; |
|
15
|
|
|
use Doctrine\Tests\OrmTestCase; |
|
16
|
|
|
use ReflectionClass; |
|
17
|
|
|
|
|
18
|
|
|
class ImportsAnnotationsTest extends OrmTestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var AnnotationReader |
|
22
|
|
|
*/ |
|
23
|
|
|
private $annotationReader; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritDoc} |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function setUp() |
|
29
|
|
|
{ |
|
30
|
|
|
// If using non-default annotation reader, everything working. |
|
31
|
|
|
//$this->annotationReader = $this->createAnnotationDriver()->getReader(); |
|
32
|
|
|
|
|
33
|
|
|
// ... but if use a default annotation reader is there a problem. |
|
34
|
|
|
$this->annotationReader = new AnnotationReader(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* If exception was thrown so is there a error during parsing something with class. |
|
39
|
|
|
* |
|
40
|
|
|
* @dataProvider dataProviderReflectionClass |
|
41
|
|
|
* |
|
42
|
|
|
* @param ReflectionClass $reflectionClass |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testClassShouldValidImportedAnnotations($reflectionClass) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->assertIsArray($this->annotationReader->getClassAnnotations($reflectionClass)); |
|
49
|
|
|
|
|
50
|
|
|
foreach ($reflectionClass->getMethods() as $reflectionMethod) { |
|
51
|
|
|
$this->assertIsArray($this->annotationReader->getMethodAnnotations($reflectionMethod)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
foreach ($reflectionClass->getProperties() as $reflectionProperty) { |
|
55
|
|
|
$this->assertIsArray($this->annotationReader->getPropertyAnnotations($reflectionProperty)); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @throws \ReflectionException |
|
61
|
|
|
* @return ReflectionClass[] |
|
62
|
|
|
*/ |
|
63
|
|
|
public function dataProviderReflectionClass() |
|
64
|
|
|
{ |
|
65
|
|
|
return [ |
|
|
|
|
|
|
66
|
|
|
[new ReflectionClass(AssociationOverride::class)], |
|
67
|
|
|
[new ReflectionClass(Cache::class)], |
|
68
|
|
|
[new ReflectionClass(ChangeTrackingPolicy::class)], |
|
69
|
|
|
[new ReflectionClass(GeneratedValue::class)], |
|
70
|
|
|
[new ReflectionClass(InheritanceType::class)], |
|
71
|
|
|
[new ReflectionClass(ManyToMany::class)], |
|
72
|
|
|
[new ReflectionClass(ManyToOne::class)], |
|
73
|
|
|
[new ReflectionClass(OneToMany::class)], |
|
74
|
|
|
[new ReflectionClass(OneToOne::class)], |
|
75
|
|
|
]; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|