|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2018 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\RDMBundle\Tests\Mapping\DriverFactories; |
|
12
|
|
|
|
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryInterface; |
|
15
|
|
|
use Doctrine\Persistence\Mapping\Driver\MappingDriver; |
|
16
|
|
|
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface; |
|
17
|
|
|
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryAggregate; |
|
18
|
|
|
|
|
19
|
|
|
final class MappingDriverFactoryAggregateTest extends TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var MappingDriverFactoryAggregate |
|
24
|
|
|
*/ |
|
25
|
|
|
private $driverFactory; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var MappingDriverFactoryInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
private $innerMappingDriverFactoryA; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var MappingDriverFactoryInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
private $innerMappingDriverFactoryB; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var MappingDriverFactoryInterface |
|
39
|
|
|
*/ |
|
40
|
|
|
private $innerMappingDriverFactoryC; |
|
41
|
|
|
|
|
42
|
|
|
public function setUp(): void |
|
43
|
|
|
{ |
|
44
|
|
|
$this->innerMappingDriverFactoryA = $this->createMock(MappingDriverFactoryInterface::class); |
|
|
|
|
|
|
45
|
|
|
$this->innerMappingDriverFactoryB = $this->createMock(MappingDriverFactoryInterface::class); |
|
|
|
|
|
|
46
|
|
|
$this->innerMappingDriverFactoryC = $this->createMock(MappingDriverFactoryInterface::class); |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
$this->driverFactory = new MappingDriverFactoryAggregate([ |
|
49
|
|
|
$this->innerMappingDriverFactoryA, |
|
50
|
|
|
$this->innerMappingDriverFactoryB, |
|
51
|
|
|
$this->innerMappingDriverFactoryC, |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @test |
|
57
|
|
|
*/ |
|
58
|
|
|
public function shouldCreatedMappingDriver() |
|
59
|
|
|
{ |
|
60
|
|
|
/** @var MappingDriver $mappingDriver */ |
|
61
|
|
|
$mappingDriver = $this->createMock(MappingDriver::class); |
|
62
|
|
|
|
|
63
|
|
|
/** @var MappingDriverInterface $expectedRdmMappingDriver */ |
|
64
|
|
|
$expectedRdmMappingDriver = $this->createMock(MappingDriverInterface::class); |
|
65
|
|
|
|
|
66
|
|
|
/** @var MappingDriverInterface $anotherRdmMappingDriver */ |
|
67
|
|
|
$anotherRdmMappingDriver = $this->createMock(MappingDriverInterface::class); |
|
68
|
|
|
|
|
69
|
|
|
$this->innerMappingDriverFactoryA->method('createRDMMappingDriver')->willReturn(null); |
|
|
|
|
|
|
70
|
|
|
$this->innerMappingDriverFactoryB->method('createRDMMappingDriver')->willReturn($expectedRdmMappingDriver); |
|
71
|
|
|
$this->innerMappingDriverFactoryC->method('createRDMMappingDriver')->willReturn($anotherRdmMappingDriver); |
|
72
|
|
|
|
|
73
|
|
|
/** @var RdmMappingDriverChain $actualRdmMappingDriver */ |
|
74
|
|
|
$actualRdmMappingDriver = $this->driverFactory->createRDMMappingDriver($mappingDriver); |
|
75
|
|
|
|
|
76
|
|
|
$this->assertSame($expectedRdmMappingDriver, $actualRdmMappingDriver); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
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..