|
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\NullableMapping; |
|
15
|
|
|
use Doctrine\DBAL\Schema\Column; |
|
16
|
|
|
use Addiks\RDMBundle\Mapping\MappingInterface; |
|
17
|
|
|
|
|
18
|
|
|
final class NullableMappingTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var NullableMapping |
|
23
|
|
|
*/ |
|
24
|
|
|
private $mapping; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var MappingInterface |
|
28
|
|
|
*/ |
|
29
|
|
|
private $innerMapping; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var Column |
|
33
|
|
|
*/ |
|
34
|
|
|
private $dbalColumn; |
|
35
|
|
|
|
|
36
|
|
|
public function setUp() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->innerMapping = $this->createMock(MappingInterface::class); |
|
|
|
|
|
|
39
|
|
|
$this->dbalColumn = $this->createMock(Column::class); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
$this->mapping = new NullableMapping($this->innerMapping, $this->dbalColumn, "some origin"); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @test |
|
46
|
|
|
*/ |
|
47
|
|
|
public function shouldHaveDBALColumn() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->assertSame($this->dbalColumn, $this->mapping->getDBALColumn()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @test |
|
54
|
|
|
*/ |
|
55
|
|
|
public function shouldHaveDeterminatorColumnName() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->dbalColumn->method('getName')->willReturn("some_column"); |
|
|
|
|
|
|
58
|
|
|
$this->assertSame("some_column", $this->mapping->getDeterminatorColumnName()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @test |
|
63
|
|
|
*/ |
|
64
|
|
|
public function shouldHaveInnerMapping() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->assertSame($this->innerMapping, $this->mapping->getInnerMapping()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @test |
|
71
|
|
|
*/ |
|
72
|
|
|
public function shouldHaveOrigin() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->assertSame("some origin", $this->mapping->describeOrigin()); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @test |
|
79
|
|
|
*/ |
|
80
|
|
|
public function shouldCollectDBALColumns() |
|
81
|
|
|
{ |
|
82
|
|
|
/** @var Column $innerColumn */ |
|
83
|
|
|
$innerColumn = $this->createMock(Column::class); |
|
84
|
|
|
|
|
85
|
|
|
$this->innerMapping->method('collectDBALColumns')->willReturn([$innerColumn]); |
|
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** @var mixed $expectedColumns */ |
|
88
|
|
|
$expectedColumns = array( |
|
89
|
|
|
$innerColumn, |
|
90
|
|
|
$this->dbalColumn |
|
91
|
|
|
); |
|
92
|
|
|
|
|
93
|
|
|
/** @var mixed $actualColumns */ |
|
94
|
|
|
$actualColumns = $this->mapping->collectDBALColumns(); |
|
95
|
|
|
|
|
96
|
|
|
$this->assertSame($expectedColumns, $actualColumns); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
|
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..