| @@ 421-453 (lines=33) @@ | ||
| 418 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 419 | } |
|
| 420 | ||
| 421 | public function testLoadContentNonPublished() |
|
| 422 | { |
|
| 423 | $repository = $this->getRepositoryMock(); |
|
| 424 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 425 | $content = $this->createMock(APIContent::class); |
|
| 426 | $versionInfo = $this |
|
| 427 | ->getMockBuilder(APIVersionInfo::class) |
|
| 428 | ->getMockForAbstractClass(); |
|
| 429 | $content |
|
| 430 | ->expects($this->once()) |
|
| 431 | ->method('getVersionInfo') |
|
| 432 | ->will($this->returnValue($versionInfo)); |
|
| 433 | $contentId = 123; |
|
| 434 | $contentService |
|
| 435 | ->expects($this->once()) |
|
| 436 | ->method('internalLoadContent') |
|
| 437 | ->with($contentId) |
|
| 438 | ->will($this->returnValue($content)); |
|
| 439 | ||
| 440 | $repository |
|
| 441 | ->expects($this->exactly(2)) |
|
| 442 | ->method('canUser') |
|
| 443 | ->will( |
|
| 444 | $this->returnValueMap( |
|
| 445 | [ |
|
| 446 | ['content', 'read', $content, null, true], |
|
| 447 | ['content', 'versionread', $content, null, true], |
|
| 448 | ] |
|
| 449 | ) |
|
| 450 | ); |
|
| 451 | ||
| 452 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 453 | } |
|
| 454 | ||
| 455 | public function testLoadContentUnauthorized() |
|
| 456 | { |
|
| @@ 478-512 (lines=35) @@ | ||
| 475 | $contentService->loadContent($contentId); |
|
| 476 | } |
|
| 477 | ||
| 478 | public function testLoadContentNotPublishedStatusUnauthorized() |
|
| 479 | { |
|
| 480 | $this->expectException(\eZ\Publish\Core\Base\Exceptions\UnauthorizedException::class); |
|
| 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 |
|