Failed Conditions
Pull Request — 2.6 (#7907)
by
unknown
07:40
created

ImportsAnnotationsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 18
c 1
b 0
f 0
dl 0
loc 57
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testClassShouldValidImportedAnnotations() 0 10 3
A setUp() 0 7 1
A dataProviderReflectionClass() 0 12 1
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 [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(array(new R...ping\OneToOne::class))) returns the type array<integer,array<integer,ReflectionClass>> which is incompatible with the documented return type ReflectionClass[].
Loading history...
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