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); |
|
|
|
|
40
|
|
|
$this->mappingB = $this->createMock(MappingInterface::class); |
|
|
|
|
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([ |
|
|
|
|
79
|
|
|
'lorem' => $columnA, |
80
|
|
|
]); |
81
|
|
|
|
82
|
|
|
$this->mappingB->method('collectDBALColumns')->willReturn([ |
|
|
|
|
83
|
|
|
'ipsum' => $columnB, |
84
|
|
|
]); |
85
|
|
|
|
86
|
|
|
$this->assertEquals([ |
87
|
|
|
'lorem' => $columnA, |
88
|
|
|
'ipsum' => $columnB |
89
|
|
|
], $this->arrayMapping->collectDBALColumns()); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
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..