| @@ 419-451 (lines=33) @@ | ||
| 416 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 417 | } |
|
| 418 | ||
| 419 | public function testLoadContentNonPublished() |
|
| 420 | { |
|
| 421 | $repository = $this->getRepositoryMock(); |
|
| 422 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 423 | $content = $this->createMock(APIContent::class); |
|
| 424 | $versionInfo = $this |
|
| 425 | ->getMockBuilder(APIVersionInfo::class) |
|
| 426 | ->getMockForAbstractClass(); |
|
| 427 | $content |
|
| 428 | ->expects($this->once()) |
|
| 429 | ->method('getVersionInfo') |
|
| 430 | ->will($this->returnValue($versionInfo)); |
|
| 431 | $contentId = 123; |
|
| 432 | $contentService |
|
| 433 | ->expects($this->once()) |
|
| 434 | ->method('internalLoadContent') |
|
| 435 | ->with($contentId) |
|
| 436 | ->will($this->returnValue($content)); |
|
| 437 | ||
| 438 | $repository |
|
| 439 | ->expects($this->exactly(2)) |
|
| 440 | ->method('canUser') |
|
| 441 | ->will( |
|
| 442 | $this->returnValueMap( |
|
| 443 | [ |
|
| 444 | ['content', 'read', $content, null, true], |
|
| 445 | ['content', 'versionread', $content, null, true], |
|
| 446 | ] |
|
| 447 | ) |
|
| 448 | ); |
|
| 449 | ||
| 450 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 451 | } |
|
| 452 | ||
| 453 | /** |
|
| 454 | * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
|
| @@ 480-512 (lines=33) @@ | ||
| 477 | /** |
|
| 478 | * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
|
| 479 | */ |
|
| 480 | public function testLoadContentNotPublishedStatusUnauthorized() |
|
| 481 | { |
|
| 482 | $repository = $this->getRepositoryMock(); |
|
| 483 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 484 | $content = $this->createMock(APIContent::class); |
|
| 485 | $versionInfo = $this |
|
| 486 | ->getMockBuilder(APIVersionInfo::class) |
|
| 487 | ->getMockForAbstractClass(); |
|
| 488 | $content |
|
| 489 | ->expects($this->once()) |
|
| 490 | ->method('getVersionInfo') |
|
| 491 | ->will($this->returnValue($versionInfo)); |
|
| 492 | $contentId = 123; |
|
| 493 | $contentService |
|
| 494 | ->expects($this->once()) |
|
| 495 | ->method('internalLoadContent') |
|
| 496 | ->with($contentId) |
|
| 497 | ->will($this->returnValue($content)); |
|
| 498 | ||
| 499 | $repository |
|
| 500 | ->expects($this->exactly(2)) |
|
| 501 | ->method('canUser') |
|
| 502 | ->will( |
|
| 503 | $this->returnValueMap( |
|
| 504 | [ |
|
| 505 | ['content', 'read', $content, null, true], |
|
| 506 | ['content', 'versionread', $content, null, false], |
|
| 507 | ] |
|
| 508 | ) |
|
| 509 | ); |
|
| 510 | ||
| 511 | $contentService->loadContent($contentId); |
|
| 512 | } |
|
| 513 | ||
| 514 | /** |
|
| 515 | * @dataProvider internalLoadContentProvider |
|