Completed
Pull Request — master (#19)
by James
02:53
created

MappingDriverChainAdapterTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine;
6
7
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
8
use Doctrine\ORM\Mapping\Column;
9
use Doctrine\ORM\Mapping\Entity;
10
use GraphQL\Doctrine\Annotation\Field;
11
use GraphQL\Doctrine\Factory\MetadataReader\MappingDriverChainAdapter;
12
use GraphQLTests\Doctrine\Blog\Model\Post;
13
14
class MappingDriverChainAdapterTest extends \PHPUnit\Framework\TestCase
15
{
16
    use TypesTrait {
17
        setUp as typeSetup;
18
    }
19
20
    private $chainAdapter;
21
22
    public function setUp(): void
23
    {
24
        $this->typeSetup();
25
26
        $config = $this->entityManager->getConfiguration();
27
        $chain = new MappingDriverChain();
28
        $chain->setDefaultDriver($config->getMetadataDriverImpl());
29
        $this->chainAdapter = new MappingDriverChainAdapter($chain);
30
    }
31
32
    public function testGetClassAnnotations(): void
33
    {
34
        self::assertNotEmpty($this->chainAdapter->getClassAnnotations(new \ReflectionClass(Post::class)));
35
    }
36
37
    public function testGetClassAnnotation(): void
38
    {
39
        self::assertNotNull($this->chainAdapter->getClassAnnotation(new \ReflectionClass(Post::class), Entity::class));
40
    }
41
42
    public function testGetMethodAnnotations(): void
43
    {
44
        self::assertNotEmpty($this->chainAdapter->getMethodAnnotations(new \ReflectionMethod(Post::class, 'getBody')));
45
    }
46
47
    public function testGetMethodAnnotation(): void
48
    {
49
        self::assertNotNull($this->chainAdapter->getMethodAnnotations(new \ReflectionMethod(Post::class, 'getBody'), Field::class));
50
    }
51
52
    public function testGetPropertyAnnotations(): void
53
    {
54
        self::assertNotEmpty($this->chainAdapter->getPropertyAnnotations(new \ReflectionProperty(Post::class, 'body')));
55
    }
56
57
    public function testGetPropertyAnnotation(): void
58
    {
59
        self::assertNotNull($this->chainAdapter->getPropertyAnnotation(new \ReflectionProperty(Post::class, 'body'), Column::class));
60
    }
61
}
62