|
@@ 258-297 (lines=40) @@
|
| 255 |
|
* |
| 256 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
| 257 |
|
*/ |
| 258 |
|
public function testLoadVersionInfoByIdPublishedVersion() |
| 259 |
|
{ |
| 260 |
|
$repository = $this->getRepositoryMock(); |
| 261 |
|
$contentServiceMock = $this->getPartlyMockedContentService(); |
| 262 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */ |
| 263 |
|
$contentHandler = $this->getPersistenceMock()->contentHandler(); |
| 264 |
|
$domainMapperMock = $this->getDomainMapperMock(); |
| 265 |
|
$versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo'); |
| 266 |
|
|
| 267 |
|
$versionInfoMock->expects($this->any()) |
| 268 |
|
->method('__get') |
| 269 |
|
->with('status') |
| 270 |
|
->will($this->returnValue(APIVersionInfo::STATUS_PUBLISHED)); |
| 271 |
|
|
| 272 |
|
$contentHandler->expects($this->once()) |
| 273 |
|
->method('loadVersionInfo') |
| 274 |
|
->with( |
| 275 |
|
$this->equalTo(42), |
| 276 |
|
$this->equalTo(24) |
| 277 |
|
)->will( |
| 278 |
|
$this->returnValue(new SPIVersionInfo()) |
| 279 |
|
); |
| 280 |
|
|
| 281 |
|
$domainMapperMock->expects($this->once()) |
| 282 |
|
->method('buildVersionInfoDomainObject') |
| 283 |
|
->with(new SPIVersionInfo()) |
| 284 |
|
->will($this->returnValue($versionInfoMock)); |
| 285 |
|
|
| 286 |
|
$repository->expects($this->once()) |
| 287 |
|
->method('canUser') |
| 288 |
|
->with( |
| 289 |
|
$this->equalTo('content'), |
| 290 |
|
$this->equalTo('read'), |
| 291 |
|
$this->equalTo($versionInfoMock) |
| 292 |
|
)->will($this->returnValue(true)); |
| 293 |
|
|
| 294 |
|
$result = $contentServiceMock->loadVersionInfoById(42, 24); |
| 295 |
|
|
| 296 |
|
$this->assertEquals($versionInfoMock, $result); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
/** |
| 300 |
|
* Test for the loadVersionInfo() method. |
|
@@ 304-343 (lines=40) @@
|
| 301 |
|
* |
| 302 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
| 303 |
|
*/ |
| 304 |
|
public function testLoadVersionInfoByIdNonPublishedVersion() |
| 305 |
|
{ |
| 306 |
|
$repository = $this->getRepositoryMock(); |
| 307 |
|
$contentServiceMock = $this->getPartlyMockedContentService(); |
| 308 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */ |
| 309 |
|
$contentHandler = $this->getPersistenceMock()->contentHandler(); |
| 310 |
|
$domainMapperMock = $this->getDomainMapperMock(); |
| 311 |
|
$versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo'); |
| 312 |
|
|
| 313 |
|
$versionInfoMock->expects($this->any()) |
| 314 |
|
->method('__get') |
| 315 |
|
->with('status') |
| 316 |
|
->will($this->returnValue(APIVersionInfo::STATUS_DRAFT)); |
| 317 |
|
|
| 318 |
|
$contentHandler->expects($this->once()) |
| 319 |
|
->method('loadVersionInfo') |
| 320 |
|
->with( |
| 321 |
|
$this->equalTo(42), |
| 322 |
|
$this->equalTo(24) |
| 323 |
|
)->will( |
| 324 |
|
$this->returnValue(new SPIVersionInfo()) |
| 325 |
|
); |
| 326 |
|
|
| 327 |
|
$domainMapperMock->expects($this->once()) |
| 328 |
|
->method('buildVersionInfoDomainObject') |
| 329 |
|
->with(new SPIVersionInfo()) |
| 330 |
|
->will($this->returnValue($versionInfoMock)); |
| 331 |
|
|
| 332 |
|
$repository->expects($this->once()) |
| 333 |
|
->method('canUser') |
| 334 |
|
->with( |
| 335 |
|
$this->equalTo('content'), |
| 336 |
|
$this->equalTo('versionread'), |
| 337 |
|
$this->equalTo($versionInfoMock) |
| 338 |
|
)->will($this->returnValue(true)); |
| 339 |
|
|
| 340 |
|
$result = $contentServiceMock->loadVersionInfoById(42, 24); |
| 341 |
|
|
| 342 |
|
$this->assertEquals($versionInfoMock, $result); |
| 343 |
|
} |
| 344 |
|
|
| 345 |
|
/** |
| 346 |
|
* Test for the loadVersionInfo() method. |