| @@ 893-913 (lines=21) @@ | ||
| 890 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations() |
|
| 891 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
|
| 892 | */ |
|
| 893 | public function testLoadRelationsThrowsUnauthorizedException() |
|
| 894 | { |
|
| 895 | /* BEGIN: Use Case */ |
|
| 896 | $mediaEditor = $this->createMediaUserVersion1(); |
|
| 897 | ||
| 898 | $setupRemoteId = '241d538ce310074e602f29f49e44e938'; |
|
| 899 | ||
| 900 | $versionInfo = $this->contentService->loadVersionInfo( |
|
| 901 | $this->contentService->loadContentInfoByRemoteId( |
|
| 902 | $setupRemoteId |
|
| 903 | ) |
|
| 904 | ); |
|
| 905 | ||
| 906 | $this->permissionResolver->setCurrentUserReference($mediaEditor); |
|
| 907 | ||
| 908 | $this->expectException(UnauthorizedException::class); |
|
| 909 | $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); |
|
| 910 | ||
| 911 | $this->contentService->loadRelations($versionInfo); |
|
| 912 | /* END: Use Case */ |
|
| 913 | } |
|
| 914 | ||
| 915 | /** |
|
| 916 | * Test for the loadRelations() method. |
|
| @@ 965-986 (lines=22) @@ | ||
| 962 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
|
| 963 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
|
| 964 | */ |
|
| 965 | public function testAddRelationThrowsUnauthorizedException() |
|
| 966 | { |
|
| 967 | /* BEGIN: Use Case */ |
|
| 968 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 969 | ||
| 970 | $draft = $this->createContentDraftVersion1(); |
|
| 971 | ||
| 972 | $versionInfo = $draft->getVersionInfo(); |
|
| 973 | ||
| 974 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 975 | ||
| 976 | $this->permissionResolver->setCurrentUserReference($this->anonymousUser); |
|
| 977 | ||
| 978 | $this->expectException(UnauthorizedException::class); |
|
| 979 | $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); |
|
| 980 | ||
| 981 | $this->contentService->addRelation( |
|
| 982 | $versionInfo, |
|
| 983 | $media |
|
| 984 | ); |
|
| 985 | /* END: Use Case */ |
|
| 986 | } |
|
| 987 | ||
| 988 | /** |
|
| 989 | * Test for the deleteRelation() method. |
|
| @@ 3194-3217 (lines=24) @@ | ||
| 3191 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
|
| 3192 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
|
| 3193 | */ |
|
| 3194 | public function testAddRelation() |
|
| 3195 | { |
|
| 3196 | /* BEGIN: Use Case */ |
|
| 3197 | // RemoteId of the "Media" content of an eZ Publish demo installation |
|
| 3198 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3199 | ||
| 3200 | $draft = $this->createContentDraftVersion1(); |
|
| 3201 | ||
| 3202 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3203 | ||
| 3204 | // Create relation between new content object and "Media" page |
|
| 3205 | $relation = $this->contentService->addRelation( |
|
| 3206 | $draft->getVersionInfo(), |
|
| 3207 | $media |
|
| 3208 | ); |
|
| 3209 | /* END: Use Case */ |
|
| 3210 | ||
| 3211 | $this->assertInstanceOf( |
|
| 3212 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Relation', |
|
| 3213 | $relation |
|
| 3214 | ); |
|
| 3215 | ||
| 3216 | return $this->contentService->loadRelations($draft->getVersionInfo()); |
|
| 3217 | } |
|
| 3218 | ||
| 3219 | /** |
|
| 3220 | * Test for the addRelation() method. |
|