| @@ 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" |
|
| @@ 3882-3907 (lines=26) @@ | ||
| 3879 | * @see \eZ\Publish\API\Repository\ContentService::deleteRelation() |
|
| 3880 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
|
| 3881 | */ |
|
| 3882 | public function testDeleteRelation() |
|
| 3883 | { |
|
| 3884 | /* BEGIN: Use Case */ |
|
| 3885 | // Remote ids of the "Media" and the "Demo Design" page of a eZ Publish |
|
| 3886 | // demo installation. |
|
| 3887 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3888 | $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f'; |
|
| 3889 | ||
| 3890 | $draft = $this->createContentDraftVersion1(); |
|
| 3891 | ||
| 3892 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3893 | $demoDesign = $this->contentService->loadContentInfoByRemoteId($demoDesignRemoteId); |
|
| 3894 | ||
| 3895 | // Establish some relations |
|
| 3896 | $this->contentService->addRelation($draft->getVersionInfo(), $media); |
|
| 3897 | $this->contentService->addRelation($draft->getVersionInfo(), $demoDesign); |
|
| 3898 | ||
| 3899 | // Delete one of the currently created relations |
|
| 3900 | $this->contentService->deleteRelation($draft->getVersionInfo(), $media); |
|
| 3901 | ||
| 3902 | // The relations array now contains only one element |
|
| 3903 | $relations = $this->contentService->loadRelations($draft->getVersionInfo()); |
|
| 3904 | /* END: Use Case */ |
|
| 3905 | ||
| 3906 | $this->assertEquals(1, count($relations)); |
|
| 3907 | } |
|
| 3908 | ||
| 3909 | /** |
|
| 3910 | * Test for the deleteRelation() method. |
|