| @@ 387-419 (lines=33) @@ | ||
| 384 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 385 | } |
|
| 386 | ||
| 387 | public function testLoadContentNonPublished() |
|
| 388 | { |
|
| 389 | $repository = $this->getRepositoryMock(); |
|
| 390 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 391 | $content = $this->createMock(APIContent::class); |
|
| 392 | $versionInfo = $this->createMock(APIVersionInfo::class); |
|
| 393 | $permissionResolver = $this->getPermissionResolverMock(); |
|
| 394 | ||
| 395 | $content |
|
| 396 | ->expects($this->once()) |
|
| 397 | ->method('getVersionInfo') |
|
| 398 | ->will($this->returnValue($versionInfo)); |
|
| 399 | $contentId = 123; |
|
| 400 | $contentService |
|
| 401 | ->expects($this->once()) |
|
| 402 | ->method('internalLoadContent') |
|
| 403 | ->with($contentId) |
|
| 404 | ->will($this->returnValue($content)); |
|
| 405 | ||
| 406 | $permissionResolver |
|
| 407 | ->expects($this->exactly(2)) |
|
| 408 | ->method('canUser') |
|
| 409 | ->will( |
|
| 410 | $this->returnValueMap( |
|
| 411 | [ |
|
| 412 | ['content', 'read', $content, [], true], |
|
| 413 | ['content', 'versionread', $content, [], true], |
|
| 414 | ] |
|
| 415 | ) |
|
| 416 | ); |
|
| 417 | ||
| 418 | $this->assertSame($content, $contentService->loadContent($contentId)); |
|
| 419 | } |
|
| 420 | ||
| 421 | public function testLoadContentUnauthorized() |
|
| 422 | { |
|
| @@ 446-481 (lines=36) @@ | ||
| 443 | $contentService->loadContent($contentId); |
|
| 444 | } |
|
| 445 | ||
| 446 | public function testLoadContentNotPublishedStatusUnauthorized() |
|
| 447 | { |
|
| 448 | $this->expectException(\eZ\Publish\Core\Base\Exceptions\UnauthorizedException::class); |
|
| 449 | ||
| 450 | $repository = $this->getRepositoryMock(); |
|
| 451 | $permissionResolver = $this->getPermissionResolverMock(); |
|
| 452 | $contentService = $this->getPartlyMockedContentService(['internalLoadContent']); |
|
| 453 | $content = $this->createMock(APIContent::class); |
|
| 454 | $versionInfo = $this |
|
| 455 | ->getMockBuilder(APIVersionInfo::class) |
|
| 456 | ->getMockForAbstractClass(); |
|
| 457 | $content |
|
| 458 | ->expects($this->once()) |
|
| 459 | ->method('getVersionInfo') |
|
| 460 | ->will($this->returnValue($versionInfo)); |
|
| 461 | $contentId = 123; |
|
| 462 | $contentService |
|
| 463 | ->expects($this->once()) |
|
| 464 | ->method('internalLoadContent') |
|
| 465 | ->with($contentId) |
|
| 466 | ->will($this->returnValue($content)); |
|
| 467 | ||
| 468 | $permissionResolver |
|
| 469 | ->expects($this->exactly(2)) |
|
| 470 | ->method('canUser') |
|
| 471 | ->will( |
|
| 472 | $this->returnValueMap( |
|
| 473 | [ |
|
| 474 | ['content', 'read', $content, [], true], |
|
| 475 | ['content', 'versionread', $content, [], false], |
|
| 476 | ] |
|
| 477 | ) |
|
| 478 | ); |
|
| 479 | ||
| 480 | $contentService->loadContent($contentId); |
|
| 481 | } |
|
| 482 | ||
| 483 | /** |
|
| 484 | * @dataProvider internalLoadContentProvider |
|