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