Failed Conditions
Pull Request — master (#62)
by Adrien
06:30 queued 04:20
created

MappingDriverChainAdapterTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
10
use GraphQL\Doctrine\Factory\MetadataReader\MappingDriverChainAdapter;
1 ignored issue
show
Bug introduced by
The type GraphQL\Doctrine\Factory...ppingDriverChainAdapter 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...
11
use GraphQLTests\Doctrine\Blog\Model\Post;
12
use PHPUnit\Framework\TestCase;
13
use ReflectionClass;
14
use ReflectionMethod;
15
use ReflectionProperty;
16
17
final class MappingDriverChainAdapterTest extends TestCase
18
{
19
    use TypesTrait {
20
        setUp as typeSetup;
21
    }
22
23
    private MappingDriverChainAdapter $chainAdapter;
24
25
    protected function setUp(): void
26
    {
27
        $this->typeSetup();
28
29
        $config = $this->entityManager->getConfiguration();
30
        $chain = new MappingDriverChain();
31
        $chain->setDefaultDriver($config->getMetadataDriverImpl());
0 ignored issues
show
Bug introduced by
It seems like $config->getMetadataDriverImpl() can also be of type null; however, parameter $driver of Doctrine\Persistence\Map...ain::setDefaultDriver() does only seem to accept Doctrine\Persistence\Mapping\Driver\MappingDriver, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        $chain->setDefaultDriver(/** @scrutinizer ignore-type */ $config->getMetadataDriverImpl());
Loading history...
32
        $this->chainAdapter = new MappingDriverChainAdapter($chain);
33
    }
34
35
    public function testGetClassAnnotations(): void
36
    {
37
        self::assertNotEmpty($this->chainAdapter->getClassAnnotations(new ReflectionClass(Post::class)));
38
    }
39
40
    public function testGetClassAnnotation(): void
41
    {
42
        self::assertNotNull($this->chainAdapter->getClassAnnotation(new ReflectionClass(Post::class), Entity::class));
43
    }
44
45
    public function testGetMethodAnnotations(): void
46
    {
47
        self::assertNotEmpty($this->chainAdapter->getMethodAnnotations(new ReflectionMethod(Post::class, 'getBody')));
48
    }
49
50
    public function testGetMethodAnnotation(): void
51
    {
52
        self::assertNotNull($this->chainAdapter->getMethodAnnotations(new ReflectionMethod(Post::class, 'getBody')));
53
    }
54
55
    public function testGetPropertyAnnotations(): void
56
    {
57
        self::assertNotEmpty($this->chainAdapter->getPropertyAnnotations(new ReflectionProperty(Post::class, 'body')));
58
    }
59
60
    public function testGetPropertyAnnotation(): void
61
    {
62
        self::assertNotNull($this->chainAdapter->getPropertyAnnotation(new ReflectionProperty(Post::class, 'body'), Column::class));
63
    }
64
}
65