|
@@ 448-467 (lines=20) @@
|
| 445 |
|
/** |
| 446 |
|
* @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
| 447 |
|
*/ |
| 448 |
|
public function testLoadContentUnauthorized() |
| 449 |
|
{ |
| 450 |
|
$repository = $this->getRepositoryMock(); |
| 451 |
|
$contentService = $this->getPartlyMockedContentService(array('internalLoadContent')); |
| 452 |
|
$content = $this->getMock('eZ\Publish\API\Repository\Values\Content\Content'); |
| 453 |
|
$contentId = 123; |
| 454 |
|
$contentService |
| 455 |
|
->expects($this->once()) |
| 456 |
|
->method('internalLoadContent') |
| 457 |
|
->with($contentId) |
| 458 |
|
->will($this->returnValue($content)); |
| 459 |
|
|
| 460 |
|
$repository |
| 461 |
|
->expects($this->once()) |
| 462 |
|
->method('canUser') |
| 463 |
|
->with('content', 'read', $content) |
| 464 |
|
->will($this->returnValue(false)); |
| 465 |
|
|
| 466 |
|
$contentService->loadContent($contentId); |
| 467 |
|
} |
| 468 |
|
|
| 469 |
|
/** |
| 470 |
|
* @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
|
@@ 5245-5269 (lines=25) @@
|
| 5242 |
|
* @covers \eZ\Publish\Core\Repository\ContentService::copyContent |
| 5243 |
|
* @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException |
| 5244 |
|
*/ |
| 5245 |
|
public function testCopyContentThrowsUnauthorizedException() |
| 5246 |
|
{ |
| 5247 |
|
$repository = $this->getRepositoryMock(); |
| 5248 |
|
$contentService = $this->getPartlyMockedContentService(array('internalLoadContentInfo')); |
| 5249 |
|
$contentInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo'); |
| 5250 |
|
$locationCreateStruct = new LocationCreateStruct(); |
| 5251 |
|
|
| 5252 |
|
$contentInfo->expects($this->any()) |
| 5253 |
|
->method('__get') |
| 5254 |
|
->with('sectionId') |
| 5255 |
|
->will($this->returnValue(42)); |
| 5256 |
|
|
| 5257 |
|
$repository->expects($this->once()) |
| 5258 |
|
->method('canUser') |
| 5259 |
|
->with( |
| 5260 |
|
'content', |
| 5261 |
|
'create', |
| 5262 |
|
$contentInfo, |
| 5263 |
|
$locationCreateStruct |
| 5264 |
|
) |
| 5265 |
|
->will($this->returnValue(false)); |
| 5266 |
|
|
| 5267 |
|
/* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */ |
| 5268 |
|
$contentService->copyContent($contentInfo, $locationCreateStruct); |
| 5269 |
|
} |
| 5270 |
|
|
| 5271 |
|
/** |
| 5272 |
|
* Test for the copyContent() method. |