GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#62)
by Simone
04:00 queued 01:32
created

MapBuilderTest::testBuildEmptyMapWithoutEntities()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 21
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 29
rs 8.8571
1
<?php
2
3
use Mado\QueryBundle\Component\Meta\MapBuilder;
4
use PHPUnit\Framework\TestCase as TestCase;
5
6
class MapBuilderTest extends TestCase
7
{
8
    public function testBuildEmptyMapWithoutEntities()
9
    {
10
        $expectedMap = [];
11
12
        $this->factory = $this
0 ignored issues
show
Bug Best Practice introduced by
The property factory does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
13
            ->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadataFactory')
14
            ->disableOriginalConstructor()
15
            ->getMock();
16
        $this->factory->expects($this->once())
17
            ->method('getAllMetadata')
18
            ->will($this->returnValue($expectedMap));
19
20
        $this->manager = $this
0 ignored issues
show
Bug Best Practice introduced by
The property manager does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
            ->getMockBuilder('Doctrine\ORM\EntityManager')
22
            ->disableOriginalConstructor()
23
            ->getMock();
24
        $this->manager->expects($this->once())
25
            ->method('getMetadataFactory')
26
            ->will($this->returnValue($this->factory));
27
28
        $mapBuilder = new MapBuilder(
29
            $this->manager
30
        );
31
32
        $map = $mapBuilder->getMap();
33
34
        $this->assertEquals(
35
            $expectedMap,
36
            $map
37
        );
38
    }
39
40
    public function testBuildMapWithParentAndRelationEntities()
41
    {
42
        $expectedMap = [];
43
44
        $this->factory = $this
0 ignored issues
show
Bug Best Practice introduced by
The property factory does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
45
            ->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadataFactory')
46
            ->disableOriginalConstructor()
47
            ->getMock();
48
        $this->factory->expects($this->once())
49
            ->method('getAllMetadata')
50
            ->will($this->returnValue(function () {
51
                return [
52
                    'SomeBundle\Entity\ParentEntity' => [
53
                        'relations' => [
54
                            'relName' => 'SomeOtherBundle\Entity\ChildEntity',
55
                        ]
56
                    ]
57
                ];
58
            }));
59
60
        $this->manager = $this
0 ignored issues
show
Bug Best Practice introduced by
The property manager does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
61
            ->getMockBuilder('Doctrine\ORM\EntityManager')
62
            ->disableOriginalConstructor()
63
            ->getMock();
64
        $this->manager->expects($this->once())
65
            ->method('getMetadataFactory')
66
            ->will($this->returnValue($this->factory));
67
68
        $mapBuilder = new MapBuilder(
69
            $this->manager
70
        );
71
72
        $map = $mapBuilder->getMap();
73
74
        $this->assertEquals(
75
            $expectedMap,
76
            $map
77
        );
78
    }
79
80
    public function testUsingCacheDoctirneIsNotCalled()
81
    {
82
        $expectedMap = [
83
            'root' => [
84
                'relations' => [
85
                    'rel_name' => 'Entity'
86
                ]
87
            ]
88
        ];
89
90
        $this->manager = $this
0 ignored issues
show
Bug Best Practice introduced by
The property manager does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
91
            ->getMockBuilder('Doctrine\ORM\EntityManager')
92
            ->disableOriginalConstructor()
93
            ->getMock();
94
95
        $this->manager->expects($this->never())
96
            ->method('getMetadataFactory');
97
98
        $mapBuilder = new MapBuilder($this->manager);
99
100
        $mapBuilder->forceCache($expectedMap);
101
102
        $map = $mapBuilder->getMap();
103
104
        $this->assertEquals(
105
            $expectedMap,
106
            $map
107
        );
108
    }
109
}
110