| @@ 461-493 (lines=33) @@ | ||
| 458 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 459 | } |
|
| 460 | ||
| 461 | public function testLoadContentNonPublished() |
|
| 462 | { |
|
| 463 | $repository = $this->getRepositoryMock(); |
|
| 464 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 465 | $content = $this->createMock(APIContent::class); |
|
| 466 | $versionInfo = $this |
|
| 467 | ->getMockBuilder(APIVersionInfo::class) |
|
| 468 | ->getMockForAbstractClass(); |
|
| 469 | $content |
|
| 470 | ->expects($this->once()) |
|
| 471 | ->method('getVersionInfo') |
|
| 472 | ->will($this->returnValue($versionInfo)); |
|
| 473 | $contentId = 123; |
|
| 474 | $contentService |
|
| 475 | ->expects($this->once()) |
|
| 476 | ->method('internalLoadContent') |
|
| 477 | ->with($contentId) |
|
| 478 | ->will($this->returnValue($content)); |
|
| 479 | ||
| 480 | $repository |
|
| 481 | ->expects($this->exactly(2)) |
|
| 482 | ->method('canUser') |
|
| 483 | ->will( |
|
| 484 | $this->returnValueMap( |
|
| 485 | [ |
|
| 486 | ['content', 'read', $content, null, true], |
|
| 487 | ['content', 'versionread', $content, null, true], |
|
| 488 | ] |
|
| 489 | ) |
|
| 490 | ); |
|
| 491 | ||
| 492 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 493 | } |
|
| 494 | ||
| 495 | /** |
|
| 496 | * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
|
| @@ 522-554 (lines=33) @@ | ||
| 519 | /** |
|
| 520 | * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
|
| 521 | */ |
|
| 522 | public function testLoadContentNotPublishedStatusUnauthorized() |
|
| 523 | { |
|
| 524 | $repository = $this->getRepositoryMock(); |
|
| 525 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 526 | $content = $this->createMock(APIContent::class); |
|
| 527 | $versionInfo = $this |
|
| 528 | ->getMockBuilder(APIVersionInfo::class) |
|
| 529 | ->getMockForAbstractClass(); |
|
| 530 | $content |
|
| 531 | ->expects($this->once()) |
|
| 532 | ->method('getVersionInfo') |
|
| 533 | ->will($this->returnValue($versionInfo)); |
|
| 534 | $contentId = 123; |
|
| 535 | $contentService |
|
| 536 | ->expects($this->once()) |
|
| 537 | ->method('internalLoadContent') |
|
| 538 | ->with($contentId) |
|
| 539 | ->will($this->returnValue($content)); |
|
| 540 | ||
| 541 | $repository |
|
| 542 | ->expects($this->exactly(2)) |
|
| 543 | ->method('canUser') |
|
| 544 | ->will( |
|
| 545 | $this->returnValueMap( |
|
| 546 | [ |
|
| 547 | ['content', 'read', $content, null, true], |
|
| 548 | ['content', 'versionread', $content, null, false], |
|
| 549 | ] |
|
| 550 | ) |
|
| 551 | ); |
|
| 552 | ||
| 553 | $contentService->loadContent($contentId); |
|
| 554 | } |
|
| 555 | ||
| 556 | /** |
|
| 557 | * @dataProvider internalLoadContentProvider |
|