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 Doctrine\Persistence\Mapping\Driver\MappingDriver; |
15
|
|
|
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain as DoctrineMappingDriverChain; |
16
|
|
|
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverFactoryInterface; |
17
|
|
|
use Addiks\RDMBundle\Mapping\DriverFactories\MappingDriverChainFactory; |
18
|
|
|
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverInterface; |
19
|
|
|
use Addiks\RDMBundle\Mapping\Drivers\MappingDriverChain as RdmMappingDriverChain; |
20
|
|
|
use Addiks\RDMBundle\Tests\Hydration\EntityExample; |
21
|
|
|
|
22
|
|
|
final class MappingDriverChainFactoryTest extends TestCase |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var MappingDriverChainFactory |
27
|
|
|
*/ |
28
|
|
|
private $driverFactory; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var MappingDriverFactoryInterface |
32
|
|
|
*/ |
33
|
|
|
private $rootMetadataDriverFactory; |
34
|
|
|
|
35
|
|
|
public function setUp(): void |
36
|
|
|
{ |
37
|
|
|
$this->rootMetadataDriverFactory = $this->createMock(MappingDriverFactoryInterface::class); |
|
|
|
|
38
|
|
|
|
39
|
|
|
$this->driverFactory = new MappingDriverChainFactory( |
40
|
|
|
$this->rootMetadataDriverFactory |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @test |
46
|
|
|
*/ |
47
|
|
|
public function shouldCreatedChainedMappingDriver() |
48
|
|
|
{ |
49
|
|
|
/** @var DoctrineMappingDriverChain $mappingDriver */ |
50
|
|
|
$mappingDriver = $this->createMock(DoctrineMappingDriverChain::class); |
51
|
|
|
|
52
|
|
|
/** @var MappingDriver $innerDriverA */ |
53
|
|
|
$innerDriverA = $this->createMock(MappingDriver::class); |
54
|
|
|
|
55
|
|
|
/** @var MappingDriver $innerDriverB */ |
56
|
|
|
$innerDriverB = $this->createMock(MappingDriver::class); |
57
|
|
|
|
58
|
|
|
/** @var MappingDriverInterface $innerRdmMappingDriverA */ |
59
|
|
|
$innerRdmMappingDriverA = $this->createMock(MappingDriverInterface::class); |
60
|
|
|
|
61
|
|
|
/** @var MappingDriverInterface $innerRdmMappingDriverB */ |
62
|
|
|
$innerRdmMappingDriverB = $this->createMock(MappingDriverInterface::class); |
63
|
|
|
|
64
|
|
|
$innerRdmMappingDriverA->expects($this->once())->method('loadRDMMetadataForClass'); |
|
|
|
|
65
|
|
|
$innerRdmMappingDriverB->expects($this->once())->method('loadRDMMetadataForClass'); |
66
|
|
|
|
67
|
|
|
$this->rootMetadataDriverFactory->method('createRDMMappingDriver')->will($this->returnValueMap([ |
|
|
|
|
68
|
|
|
[$innerDriverA, $innerRdmMappingDriverA], |
69
|
|
|
[$innerDriverB, $innerRdmMappingDriverB], |
70
|
|
|
])); |
71
|
|
|
|
72
|
|
|
$mappingDriver->method('getDrivers')->willReturn([ |
|
|
|
|
73
|
|
|
$innerDriverA, |
74
|
|
|
$innerDriverB |
75
|
|
|
]); |
76
|
|
|
|
77
|
|
|
/** @var RdmMappingDriverChain $rdmMappingDriver */ |
78
|
|
|
$rdmMappingDriver = $this->driverFactory->createRDMMappingDriver($mappingDriver); |
79
|
|
|
|
80
|
|
|
$this->assertInstanceOf(RdmMappingDriverChain::class, $rdmMappingDriver); |
81
|
|
|
|
82
|
|
|
$rdmMappingDriver->loadRDMMetadataForClass(EntityExample::class); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
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..