1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File contains: eZ\Publish\Core\Repository\Tests\Service\Mock\DomainMapperTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\Repository\Tests\Service\Mock; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\Values\Content\VersionInfo as APIVersionInfo; |
12
|
|
|
use eZ\Publish\Core\Repository\Tests\Service\Mock\Base as BaseServiceMockTest; |
13
|
|
|
use eZ\Publish\Core\Repository\Helper\DomainMapper; |
14
|
|
|
use eZ\Publish\SPI\Persistence\Content\VersionInfo as SPIVersionInfo; |
15
|
|
|
use eZ\Publish\SPI\Persistence\Content\ContentInfo as SPIContentInfo; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Mock test case for internal DomainMapper. |
19
|
|
|
*/ |
20
|
|
|
class DomainMapperTest extends BaseServiceMockTest |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @covers \eZ\Publish\Core\Repository\Helper\DomainMapper::buildVersionInfoDomainObject |
24
|
|
|
* @dataProvider providerForBuildVersionInfo |
25
|
|
|
*/ |
26
|
|
|
public function testBuildVersionInfo(SPIVersionInfo $spiVersionInfo, array $languages, array $expected) |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
$languageHandlerMock = $this->getLanguageHandlerMock(); |
29
|
|
|
$languageHandlerMock->expects($this->never())->method('load'); |
30
|
|
|
|
31
|
|
|
$versionInfo = $this->getDomainMapper()->buildVersionInfoDomainObject($spiVersionInfo); |
32
|
|
|
$this->assertInstanceOf('eZ\\Publish\\Core\\Repository\\Values\\Content\\VersionInfo', $versionInfo); |
33
|
|
|
|
34
|
|
|
foreach ($expected as $expectedProperty => $expectedValue) { |
35
|
|
|
$this->assertAttributeSame( |
36
|
|
|
$expectedValue, |
37
|
|
|
$expectedProperty, |
38
|
|
|
$versionInfo |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function providerForBuildVersionInfo() |
44
|
|
|
{ |
45
|
|
|
return array( |
46
|
|
|
array( |
47
|
|
|
new SPIVersionInfo( |
48
|
|
|
array( |
49
|
|
|
'status' => 44, |
50
|
|
|
'contentInfo' => new SPIContentInfo(), |
51
|
|
|
) |
52
|
|
|
), |
53
|
|
|
array(), |
54
|
|
|
array('status' => APIVersionInfo::STATUS_DRAFT), |
55
|
|
|
), |
56
|
|
|
array( |
57
|
|
|
new SPIVersionInfo( |
58
|
|
|
array( |
59
|
|
|
'status' => SPIVersionInfo::STATUS_DRAFT, |
60
|
|
|
'contentInfo' => new SPIContentInfo(), |
61
|
|
|
) |
62
|
|
|
), |
63
|
|
|
array(), |
64
|
|
|
array('status' => APIVersionInfo::STATUS_DRAFT), |
65
|
|
|
), |
66
|
|
|
array( |
67
|
|
|
new SPIVersionInfo( |
68
|
|
|
array( |
69
|
|
|
'status' => SPIVersionInfo::STATUS_PENDING, |
70
|
|
|
'contentInfo' => new SPIContentInfo(), |
71
|
|
|
) |
72
|
|
|
), |
73
|
|
|
array(), |
74
|
|
|
array('status' => APIVersionInfo::STATUS_DRAFT), |
75
|
|
|
), |
76
|
|
|
array( |
77
|
|
|
new SPIVersionInfo( |
78
|
|
|
array( |
79
|
|
|
'status' => SPIVersionInfo::STATUS_ARCHIVED, |
80
|
|
|
'contentInfo' => new SPIContentInfo(), |
81
|
|
|
'languageCodes' => array('eng-GB', 'nor-NB', 'fre-FR'), |
82
|
|
|
) |
83
|
|
|
), |
84
|
|
|
array(1 => 'eng-GB', 3 => 'nor-NB', 5 => 'fre-FR'), |
85
|
|
|
array( |
86
|
|
|
'status' => APIVersionInfo::STATUS_ARCHIVED, |
87
|
|
|
'languageCodes' => array('eng-GB', 'nor-NB', 'fre-FR'), |
88
|
|
|
), |
89
|
|
|
), |
90
|
|
|
array( |
91
|
|
|
new SPIVersionInfo( |
92
|
|
|
array( |
93
|
|
|
'status' => SPIVersionInfo::STATUS_PUBLISHED, |
94
|
|
|
'contentInfo' => new SPIContentInfo(), |
95
|
|
|
) |
96
|
|
|
), |
97
|
|
|
array(), |
98
|
|
|
array('status' => APIVersionInfo::STATUS_PUBLISHED), |
99
|
|
|
), |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Returns DomainMapper. |
105
|
|
|
* |
106
|
|
|
* @return \eZ\Publish\Core\Repository\Helper\DomainMapper |
107
|
|
|
*/ |
108
|
|
|
protected function getDomainMapper() |
109
|
|
|
{ |
110
|
|
|
return new DomainMapper( |
111
|
|
|
$this->getPersistenceMockHandler('Content\\Handler'), |
112
|
|
|
$this->getPersistenceMockHandler('Content\\Location\\Handler'), |
113
|
|
|
$this->getTypeHandlerMock(), |
|
|
|
|
114
|
|
|
$this->getLanguageHandlerMock(), |
|
|
|
|
115
|
|
|
$this->getFieldTypeRegistryMock() |
|
|
|
|
116
|
|
|
); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\Language\Handler|\PHPUnit_Framework_MockObject_MockObject |
121
|
|
|
*/ |
122
|
|
|
protected function getLanguageHandlerMock() |
123
|
|
|
{ |
124
|
|
|
return $this->getPersistenceMockHandler('Content\\Language\\Handler'); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\Type\Handler|\PHPUnit_Framework_MockObject_MockObject |
129
|
|
|
*/ |
130
|
|
|
protected function getTypeHandlerMock() |
131
|
|
|
{ |
132
|
|
|
return $this->getPersistenceMockHandler('Content\\Type\\Handler'); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.