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