Failed Conditions
Pull Request — master (#43)
by
unknown
13:19 queued 11:18
created

MappingDriverChainAdapterTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
eloc 15
dl 0
loc 49
rs 10
c 2
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetMethodAnnotation() 0 3 1
A testGetPropertyAnnotations() 0 3 1
A testGetClassAnnotation() 0 3 1
A testGetPropertyAnnotation() 0 3 1
A setUp() 0 8 1
A testGetMethodAnnotations() 0 3 1
A testGetClassAnnotations() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine;
6
7
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
1 ignored issue
show
Bug introduced by
The type Doctrine\Common\Persiste...iver\MappingDriverChain was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Doctrine\ORM\Mapping\Column;
9
use Doctrine\ORM\Mapping\Entity;
10
use GraphQL\Doctrine\Factory\MetadataReader\MappingDriverChainAdapter;
11
use GraphQLTests\Doctrine\Blog\Model\Post;
12
use ReflectionClass;
13
use ReflectionMethod;
14
use ReflectionProperty;
15
16
final class MappingDriverChainAdapterTest extends \PHPUnit\Framework\TestCase
17
{
18
    use TypesTrait {
19
        setUp as typeSetup;
20
    }
21
22
    /**
23
     * @var MappingDriverChainAdapter
24
     */
25
    private $chainAdapter;
26
27
    protected function setUp(): void
28
    {
29
        $this->typeSetup();
30
31
        $config = $this->entityManager->getConfiguration();
32
        $chain = new MappingDriverChain();
33
        $chain->setDefaultDriver($config->getMetadataDriverImpl());
34
        $this->chainAdapter = new MappingDriverChainAdapter($chain);
35
    }
36
37
    public function testGetClassAnnotations(): void
38
    {
39
        self::assertNotEmpty($this->chainAdapter->getClassAnnotations(new ReflectionClass(Post::class)));
40
    }
41
42
    public function testGetClassAnnotation(): void
43
    {
44
        self::assertNotNull($this->chainAdapter->getClassAnnotation(new ReflectionClass(Post::class), Entity::class));
45
    }
46
47
    public function testGetMethodAnnotations(): void
48
    {
49
        self::assertNotEmpty($this->chainAdapter->getMethodAnnotations(new ReflectionMethod(Post::class, 'getBody')));
50
    }
51
52
    public function testGetMethodAnnotation(): void
53
    {
54
        self::assertNotNull($this->chainAdapter->getMethodAnnotations(new ReflectionMethod(Post::class, 'getBody')));
55
    }
56
57
    public function testGetPropertyAnnotations(): void
58
    {
59
        self::assertNotEmpty($this->chainAdapter->getPropertyAnnotations(new ReflectionProperty(Post::class, 'body')));
60
    }
61
62
    public function testGetPropertyAnnotation(): void
63
    {
64
        self::assertNotNull($this->chainAdapter->getPropertyAnnotation(new ReflectionProperty(Post::class, 'body'), Column::class));
65
    }
66
}
67