Completed
Push — master ( 203e38...2cdd54 )
by Gerrit
13:04
created

ArrayMappingTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (C) 2017  Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 * @license GPL-3.0
8
 * @author Gerrit Addiks <[email protected]>
9
 */
10
11
namespace Addiks;
12
13
use PHPUnit\Framework\TestCase;
14
use Addiks\RDMBundle\Mapping\ArrayMapping;
15
use Addiks\RDMBundle\Mapping\MappingInterface;
16
use Doctrine\DBAL\Schema\Column;
17
use InvalidArgumentException;
18
19
final class ArrayMappingTest extends TestCase
20
{
21
22
    /**
23
     * @var ArrayMapping
24
     */
25
    private $arrayMapping;
26
27
    /**
28
     * @var MappingInterface
29
     */
30
    private $mappingA;
31
32
    /**
33
     * @var MappingInterface
34
     */
35
    private $mappingB;
36
37
    public function setUp()
38
    {
39
        $this->mappingA = $this->createMock(MappingInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\Addik...appingInterface::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<Addiks\RDMBundle\Mapping\MappingInterface> of property $mappingA.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
        $this->mappingB = $this->createMock(MappingInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\Addik...appingInterface::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<Addiks\RDMBundle\Mapping\MappingInterface> of property $mappingB.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
42
        $this->arrayMapping = new ArrayMapping([
43
            'foo' => $this->mappingA,
44
            'bar' => $this->mappingB,
45
        ], "Some Origin");
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function shouldHaveOrigin()
52
    {
53
        $this->assertEquals("Some Origin", $this->arrayMapping->describeOrigin());
54
    }
55
56
    /**
57
     * @test
58
     */
59
    public function shouldStoreEntryMappings()
60
    {
61
        $this->assertEquals([
62
            'foo' => $this->mappingA,
63
            'bar' => $this->mappingB,
64
        ], $this->arrayMapping->getEntryMappings());
65
    }
66
67
    /**
68
     * @test
69
     */
70
    public function shouldCollectDBALColumns()
71
    {
72
        /** @var Column $columnA */
73
        $columnA = $this->createMock(Column::class);
74
75
        /** @var Column $columnB */
76
        $columnB = $this->createMock(Column::class);
77
78
        $this->mappingA->method('collectDBALColumns')->willReturn([
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\RDMBundle\Mapping\MappingInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
79
            'lorem' => $columnA,
80
        ]);
81
82
        $this->mappingB->method('collectDBALColumns')->willReturn([
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Addiks\RDMBundle\Mapping\MappingInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
83
            'ipsum' => $columnB,
84
        ]);
85
86
        $this->assertEquals([
87
            'lorem' => $columnA,
88
            'ipsum' => $columnB
89
        ], $this->arrayMapping->collectDBALColumns());
90
    }
91
92
}
93