| @@ 427-458 (lines=32) @@ | ||
| 424 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 425 | } |
|
| 426 | ||
| 427 | public function testLoadContentNonPublished() |
|
| 428 | { |
|
| 429 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 430 | $content = $this->createMock(APIContent::class); |
|
| 431 | $versionInfo = $this->createMock(APIVersionInfo::class); |
|
| 432 | $permissionResolver = $this->getPermissionResolverMock(); |
|
| 433 | ||
| 434 | $content |
|
| 435 | ->expects($this->once()) |
|
| 436 | ->method('getVersionInfo') |
|
| 437 | ->will($this->returnValue($versionInfo)); |
|
| 438 | $contentId = 123; |
|
| 439 | $contentService |
|
| 440 | ->expects($this->once()) |
|
| 441 | ->method('internalLoadContent') |
|
| 442 | ->with($contentId) |
|
| 443 | ->will($this->returnValue($content)); |
|
| 444 | ||
| 445 | $permissionResolver |
|
| 446 | ->expects($this->exactly(2)) |
|
| 447 | ->method('canUser') |
|
| 448 | ->will( |
|
| 449 | $this->returnValueMap( |
|
| 450 | [ |
|
| 451 | ['content', 'read', $content, [], true], |
|
| 452 | ['content', 'versionread', $content, [], true], |
|
| 453 | ] |
|
| 454 | ) |
|
| 455 | ); |
|
| 456 | ||
| 457 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 458 | } |
|
| 459 | ||
| 460 | public function testLoadContentUnauthorized() |
|
| 461 | { |
|
| @@ 484-518 (lines=35) @@ | ||
| 481 | $contentService->loadContent($contentId); |
|
| 482 | } |
|
| 483 | ||
| 484 | public function testLoadContentNotPublishedStatusUnauthorized() |
|
| 485 | { |
|
| 486 | $this->expectException(\eZ\Publish\Core\Base\Exceptions\UnauthorizedException::class); |
|
| 487 | ||
| 488 | $permissionResolver = $this->getPermissionResolverMock(); |
|
| 489 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 490 | $content = $this->createMock(APIContent::class); |
|
| 491 | $versionInfo = $this |
|
| 492 | ->getMockBuilder(APIVersionInfo::class) |
|
| 493 | ->getMockForAbstractClass(); |
|
| 494 | $content |
|
| 495 | ->expects($this->once()) |
|
| 496 | ->method('getVersionInfo') |
|
| 497 | ->will($this->returnValue($versionInfo)); |
|
| 498 | $contentId = 123; |
|
| 499 | $contentService |
|
| 500 | ->expects($this->once()) |
|
| 501 | ->method('internalLoadContent') |
|
| 502 | ->with($contentId) |
|
| 503 | ->will($this->returnValue($content)); |
|
| 504 | ||
| 505 | $permissionResolver |
|
| 506 | ->expects($this->exactly(2)) |
|
| 507 | ->method('canUser') |
|
| 508 | ->will( |
|
| 509 | $this->returnValueMap( |
|
| 510 | [ |
|
| 511 | ['content', 'read', $content, [], true], |
|
| 512 | ['content', 'versionread', $content, [], false], |
|
| 513 | ] |
|
| 514 | ) |
|
| 515 | ); |
|
| 516 | ||
| 517 | $contentService->loadContent($contentId); |
|
| 518 | } |
|
| 519 | ||
| 520 | /** |
|
| 521 | * @dataProvider internalLoadContentProvider |
|