| @@ 1026-1050 (lines=25) @@ | ||
| 1023 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() |
|
| 1024 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation |
|
| 1025 | */ |
|
| 1026 | public function testDeleteRelationThrowsUnauthorizedException() |
|
| 1027 | { |
|
| 1028 | /* BEGIN: Use Case */ |
|
| 1029 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 1030 | $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f'; |
|
| 1031 | ||
| 1032 | $draft = $this->createContentDraftVersion1(); |
|
| 1033 | ||
| 1034 | $versionInfo = $draft->getVersionInfo(); |
|
| 1035 | ||
| 1036 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 1037 | $demoDesign = $this->contentService->loadContentInfoByRemoteId($demoDesignRemoteId); |
|
| 1038 | ||
| 1039 | // Establish some relations |
|
| 1040 | $this->contentService->addRelation($draft->getVersionInfo(), $media); |
|
| 1041 | $this->contentService->addRelation($draft->getVersionInfo(), $demoDesign); |
|
| 1042 | ||
| 1043 | $this->permissionResolver->setCurrentUserReference($this->anonymousUser); |
|
| 1044 | ||
| 1045 | $this->expectException(UnauthorizedException::class); |
|
| 1046 | $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); |
|
| 1047 | ||
| 1048 | $this->contentService->deleteRelation($versionInfo, $media); |
|
| 1049 | /* END: Use Case */ |
|
| 1050 | } |
|
| 1051 | ||
| 1052 | /** |
|
| 1053 | * Creates a pseudo editor with a limitation to objects in the "Media/Images" |
|
| @@ 3916-3941 (lines=26) @@ | ||
| 3913 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() |
|
| 3914 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
|
| 3915 | */ |
|
| 3916 | public function testDeleteRelation() |
|
| 3917 | { |
|
| 3918 | /* BEGIN: Use Case */ |
|
| 3919 | // Remote ids of the "Media" and the "Demo Design" page of a eZ Publish |
|
| 3920 | // demo installation. |
|
| 3921 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3922 | $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f'; |
|
| 3923 | ||
| 3924 | $draft = $this->createContentDraftVersion1(); |
|
| 3925 | ||
| 3926 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3927 | $demoDesign = $this->contentService->loadContentInfoByRemoteId($demoDesignRemoteId); |
|
| 3928 | ||
| 3929 | // Establish some relations |
|
| 3930 | $this->contentService->addRelation($draft->getVersionInfo(), $media); |
|
| 3931 | $this->contentService->addRelation($draft->getVersionInfo(), $demoDesign); |
|
| 3932 | ||
| 3933 | // Delete one of the currently created relations |
|
| 3934 | $this->contentService->deleteRelation($draft->getVersionInfo(), $media); |
|
| 3935 | ||
| 3936 | // The relations array now contains only one element |
|
| 3937 | $relations = $this->contentService->loadRelations($draft->getVersionInfo()); |
|
| 3938 | /* END: Use Case */ |
|
| 3939 | ||
| 3940 | $this->assertEquals(1, count($relations)); |
|
| 3941 | } |
|
| 3942 | ||
| 3943 | /** |
|
| 3944 | * Test for the deleteRelation() method. |
|