@@ 66-84 (lines=19) @@ | ||
63 | * @see \eZ\Publish\API\Repository\ContentService::createContent() |
|
64 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContent |
|
65 | */ |
|
66 | public function testCreateContentThrowsUnauthorizedException() |
|
67 | { |
|
68 | $this->permissionResolver->setCurrentUserReference($this->anonymousUser); |
|
69 | ||
70 | $contentTypeService = $this->getRepository()->getContentTypeService(); |
|
71 | ||
72 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
73 | ||
74 | $contentCreate = $this->contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
75 | $contentCreate->setField('name', 'Awesome Sindelfingen forum'); |
|
76 | ||
77 | $contentCreate->remoteId = 'abcdef0123456789abcdef0123456789'; |
|
78 | $contentCreate->alwaysAvailable = true; |
|
79 | ||
80 | $this->expectException(UnauthorizedException::class); |
|
81 | $this->expectExceptionMessageMatches('/\'create\' \'content\'/'); |
|
82 | ||
83 | $this->contentService->createContent($contentCreate); |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * Test for the createContent() method. |
|
@@ 679-699 (lines=21) @@ | ||
676 | * @see \eZ\Publish\API\Repository\ContentService::updateContent() |
|
677 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
|
678 | */ |
|
679 | public function testUpdateContentThrowsUnauthorizedException() |
|
680 | { |
|
681 | $draftVersion2 = $this->createContentDraftVersion2(); |
|
682 | ||
683 | $versionInfo = $draftVersion2->getVersionInfo(); |
|
684 | ||
685 | $this->permissionResolver->setCurrentUserReference($this->anonymousUser); |
|
686 | ||
687 | // Create an update struct and modify some fields |
|
688 | $contentUpdate = $this->contentService->newContentUpdateStruct(); |
|
689 | $contentUpdate->setField('name', 'An awesome² story about ezp.'); |
|
690 | $contentUpdate->setField('name', 'An awesome²³ story about ezp.', 'eng-GB'); |
|
691 | ||
692 | $contentUpdate->initialLanguageCode = 'eng-US'; |
|
693 | ||
694 | $this->expectException(UnauthorizedException::class); |
|
695 | /* TODO - the `content/edit` policy should be probably needed */ |
|
696 | $this->expectExceptionMessageMatches('/\'versionread\' \'content\'/'); |
|
697 | ||
698 | $this->contentService->updateContent($versionInfo, $contentUpdate); |
|
699 | } |
|
700 | ||
701 | /** |
|
702 | * Test for the publishVersion() method. |