|
@@ 312-350 (lines=39) @@
|
| 309 |
|
* |
| 310 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
| 311 |
|
*/ |
| 312 |
|
public function testLoadVersionInfoByIdPublishedVersion() |
| 313 |
|
{ |
| 314 |
|
$repository = $this->getRepositoryMock(); |
| 315 |
|
$contentServiceMock = $this->getPartlyMockedContentService(); |
| 316 |
|
/** @var \PHPUnit\Framework\MockObject\MockObject $contentHandler */ |
| 317 |
|
$contentHandler = $this->getPersistenceMock()->contentHandler(); |
| 318 |
|
$domainMapperMock = $this->getDomainMapperMock(); |
| 319 |
|
$versionInfoMock = $this->createMock(APIVersionInfo::class); |
| 320 |
|
|
| 321 |
|
$versionInfoMock->expects($this->once()) |
| 322 |
|
->method('isPublished') |
| 323 |
|
->willReturn(true); |
| 324 |
|
|
| 325 |
|
$contentHandler->expects($this->once()) |
| 326 |
|
->method('loadVersionInfo') |
| 327 |
|
->with( |
| 328 |
|
$this->equalTo(42), |
| 329 |
|
$this->equalTo(24) |
| 330 |
|
)->will( |
| 331 |
|
$this->returnValue(new SPIVersionInfo()) |
| 332 |
|
); |
| 333 |
|
|
| 334 |
|
$domainMapperMock->expects($this->once()) |
| 335 |
|
->method('buildVersionInfoDomainObject') |
| 336 |
|
->with(new SPIVersionInfo()) |
| 337 |
|
->will($this->returnValue($versionInfoMock)); |
| 338 |
|
|
| 339 |
|
$repository->expects($this->once()) |
| 340 |
|
->method('canUser') |
| 341 |
|
->with( |
| 342 |
|
$this->equalTo('content'), |
| 343 |
|
$this->equalTo('read'), |
| 344 |
|
$this->equalTo($versionInfoMock) |
| 345 |
|
)->will($this->returnValue(true)); |
| 346 |
|
|
| 347 |
|
$result = $contentServiceMock->loadVersionInfoById(42, 24); |
| 348 |
|
|
| 349 |
|
$this->assertEquals($versionInfoMock, $result); |
| 350 |
|
} |
| 351 |
|
|
| 352 |
|
/** |
| 353 |
|
* Test for the loadVersionInfo() method. |
|
@@ 357-395 (lines=39) @@
|
| 354 |
|
* |
| 355 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById |
| 356 |
|
*/ |
| 357 |
|
public function testLoadVersionInfoByIdNonPublishedVersion() |
| 358 |
|
{ |
| 359 |
|
$repository = $this->getRepositoryMock(); |
| 360 |
|
$contentServiceMock = $this->getPartlyMockedContentService(); |
| 361 |
|
/** @var \PHPUnit\Framework\MockObject\MockObject $contentHandler */ |
| 362 |
|
$contentHandler = $this->getPersistenceMock()->contentHandler(); |
| 363 |
|
$domainMapperMock = $this->getDomainMapperMock(); |
| 364 |
|
$versionInfoMock = $this->createMock(APIVersionInfo::class); |
| 365 |
|
|
| 366 |
|
$versionInfoMock->expects($this->once()) |
| 367 |
|
->method('isPublished') |
| 368 |
|
->willReturn(false); |
| 369 |
|
|
| 370 |
|
$contentHandler->expects($this->once()) |
| 371 |
|
->method('loadVersionInfo') |
| 372 |
|
->with( |
| 373 |
|
$this->equalTo(42), |
| 374 |
|
$this->equalTo(24) |
| 375 |
|
)->will( |
| 376 |
|
$this->returnValue(new SPIVersionInfo()) |
| 377 |
|
); |
| 378 |
|
|
| 379 |
|
$domainMapperMock->expects($this->once()) |
| 380 |
|
->method('buildVersionInfoDomainObject') |
| 381 |
|
->with(new SPIVersionInfo()) |
| 382 |
|
->will($this->returnValue($versionInfoMock)); |
| 383 |
|
|
| 384 |
|
$repository->expects($this->once()) |
| 385 |
|
->method('canUser') |
| 386 |
|
->with( |
| 387 |
|
$this->equalTo('content'), |
| 388 |
|
$this->equalTo('versionread'), |
| 389 |
|
$this->equalTo($versionInfoMock) |
| 390 |
|
)->will($this->returnValue(true)); |
| 391 |
|
|
| 392 |
|
$result = $contentServiceMock->loadVersionInfoById(42, 24); |
| 393 |
|
|
| 394 |
|
$this->assertEquals($versionInfoMock, $result); |
| 395 |
|
} |
| 396 |
|
|
| 397 |
|
/** |
| 398 |
|
* Test for the loadVersionInfo() method. |