|
@@ 126-168 (lines=43) @@
|
| 123 |
|
* |
| 124 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
| 125 |
|
*/ |
| 126 |
|
public function testLoadVersionInfoById() |
| 127 |
|
{ |
| 128 |
|
$repository = $this->getRepositoryMock(); |
| 129 |
|
$contentServiceMock = $this->getPartlyMockedContentService(['loadContentInfo']); |
| 130 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */ |
| 131 |
|
$contentHandler = $this->getPersistenceMock()->contentHandler(); |
| 132 |
|
$domainMapperMock = $this->getDomainMapperMock(); |
| 133 |
|
$versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo'); |
| 134 |
|
|
| 135 |
|
$versionInfoMock->expects($this->any()) |
| 136 |
|
->method('__get') |
| 137 |
|
->with('status') |
| 138 |
|
->will($this->returnValue(APIVersionInfo::STATUS_PUBLISHED)); |
| 139 |
|
|
| 140 |
|
$contentServiceMock->expects($this->never()) |
| 141 |
|
->method('loadContentInfo'); |
| 142 |
|
|
| 143 |
|
$contentHandler->expects($this->once()) |
| 144 |
|
->method('loadVersionInfo') |
| 145 |
|
->with( |
| 146 |
|
$this->equalTo(42), |
| 147 |
|
$this->equalTo(null) |
| 148 |
|
)->will( |
| 149 |
|
$this->returnValue(new SPIVersionInfo()) |
| 150 |
|
); |
| 151 |
|
|
| 152 |
|
$domainMapperMock->expects($this->once()) |
| 153 |
|
->method('buildVersionInfoDomainObject') |
| 154 |
|
->with(new SPIVersionInfo()) |
| 155 |
|
->will($this->returnValue($versionInfoMock)); |
| 156 |
|
|
| 157 |
|
$repository->expects($this->once()) |
| 158 |
|
->method('canUser') |
| 159 |
|
->with( |
| 160 |
|
$this->equalTo('content'), |
| 161 |
|
$this->equalTo('read'), |
| 162 |
|
$this->equalTo($versionInfoMock) |
| 163 |
|
)->will($this->returnValue(true)); |
| 164 |
|
|
| 165 |
|
$result = $contentServiceMock->loadVersionInfoById(42); |
| 166 |
|
|
| 167 |
|
$this->assertEquals($versionInfoMock, $result); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
/** |
| 171 |
|
* Test for the loadVersionInfo() method, of a draft. |
|
@@ 176-218 (lines=43) @@
|
| 173 |
|
* @depends testLoadVersionInfoById |
| 174 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
| 175 |
|
*/ |
| 176 |
|
public function testLoadVersionInfoByIdAndVersionNumber() |
| 177 |
|
{ |
| 178 |
|
$repository = $this->getRepositoryMock(); |
| 179 |
|
$contentServiceMock = $this->getPartlyMockedContentService(['loadContentInfo']); |
| 180 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */ |
| 181 |
|
$contentHandler = $this->getPersistenceMock()->contentHandler(); |
| 182 |
|
$domainMapperMock = $this->getDomainMapperMock(); |
| 183 |
|
$versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo'); |
| 184 |
|
|
| 185 |
|
$versionInfoMock->expects($this->any()) |
| 186 |
|
->method('__get') |
| 187 |
|
->with('status') |
| 188 |
|
->will($this->returnValue(APIVersionInfo::STATUS_DRAFT)); |
| 189 |
|
|
| 190 |
|
$contentServiceMock->expects($this->never()) |
| 191 |
|
->method('loadContentInfo'); |
| 192 |
|
|
| 193 |
|
$contentHandler->expects($this->once()) |
| 194 |
|
->method('loadVersionInfo') |
| 195 |
|
->with( |
| 196 |
|
$this->equalTo(42), |
| 197 |
|
$this->equalTo(2) |
| 198 |
|
)->will( |
| 199 |
|
$this->returnValue(new SPIVersionInfo()) |
| 200 |
|
); |
| 201 |
|
|
| 202 |
|
$domainMapperMock->expects($this->once()) |
| 203 |
|
->method('buildVersionInfoDomainObject') |
| 204 |
|
->with(new SPIVersionInfo()) |
| 205 |
|
->will($this->returnValue($versionInfoMock)); |
| 206 |
|
|
| 207 |
|
$repository->expects($this->once()) |
| 208 |
|
->method('canUser') |
| 209 |
|
->with( |
| 210 |
|
$this->equalTo('content'), |
| 211 |
|
$this->equalTo('versionread'), |
| 212 |
|
$this->equalTo($versionInfoMock) |
| 213 |
|
)->will($this->returnValue(true)); |
| 214 |
|
|
| 215 |
|
$result = $contentServiceMock->loadVersionInfoById(42, 2); |
| 216 |
|
|
| 217 |
|
$this->assertEquals($versionInfoMock, $result); |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
/** |
| 221 |
|
* Test for the loadVersionInfo() method. |