| @@ 925-945 (lines=21) @@ | ||
| 922 | * @see \eZ\Publish\API\Repository\ContentService::loadRelations() |
|
| 923 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations |
|
| 924 | */ |
|
| 925 | public function testLoadRelationsThrowsUnauthorizedException() |
|
| 926 | { |
|
| 927 | /* BEGIN: Use Case */ |
|
| 928 | $mediaEditor = $this->createMediaUserVersion1(); |
|
| 929 | ||
| 930 | $setupRemoteId = '241d538ce310074e602f29f49e44e938'; |
|
| 931 | ||
| 932 | $versionInfo = $this->contentService->loadVersionInfo( |
|
| 933 | $this->contentService->loadContentInfoByRemoteId( |
|
| 934 | $setupRemoteId |
|
| 935 | ) |
|
| 936 | ); |
|
| 937 | ||
| 938 | $this->permissionResolver->setCurrentUserReference($mediaEditor); |
|
| 939 | ||
| 940 | $this->expectException(UnauthorizedException::class); |
|
| 941 | $this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); |
|
| 942 | ||
| 943 | $this->contentService->loadRelations($versionInfo); |
|
| 944 | /* END: Use Case */ |
|
| 945 | } |
|
| 946 | ||
| 947 | /** |
|
| 948 | * Test for the loadRelations() method. |
|
| @@ 997-1018 (lines=22) @@ | ||
| 994 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
|
| 995 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation |
|
| 996 | */ |
|
| 997 | public function testAddRelationThrowsUnauthorizedException() |
|
| 998 | { |
|
| 999 | /* BEGIN: Use Case */ |
|
| 1000 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 1001 | ||
| 1002 | $draft = $this->createContentDraftVersion1(); |
|
| 1003 | ||
| 1004 | $versionInfo = $draft->getVersionInfo(); |
|
| 1005 | ||
| 1006 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 1007 | ||
| 1008 | $this->permissionResolver->setCurrentUserReference($this->anonymousUser); |
|
| 1009 | ||
| 1010 | $this->expectException(UnauthorizedException::class); |
|
| 1011 | $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); |
|
| 1012 | ||
| 1013 | $this->contentService->addRelation( |
|
| 1014 | $versionInfo, |
|
| 1015 | $media |
|
| 1016 | ); |
|
| 1017 | /* END: Use Case */ |
|
| 1018 | } |
|
| 1019 | ||
| 1020 | /** |
|
| 1021 | * Test for the deleteRelation() method. |
|
| @@ 3294-3317 (lines=24) @@ | ||
| 3291 | * @see \eZ\Publish\API\Repository\ContentService::addRelation() |
|
| 3292 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
|
| 3293 | */ |
|
| 3294 | public function testAddRelation() |
|
| 3295 | { |
|
| 3296 | /* BEGIN: Use Case */ |
|
| 3297 | // RemoteId of the "Media" content of an eZ Publish demo installation |
|
| 3298 | $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262'; |
|
| 3299 | ||
| 3300 | $draft = $this->createContentDraftVersion1(); |
|
| 3301 | ||
| 3302 | $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId); |
|
| 3303 | ||
| 3304 | // Create relation between new content object and "Media" page |
|
| 3305 | $relation = $this->contentService->addRelation( |
|
| 3306 | $draft->getVersionInfo(), |
|
| 3307 | $media |
|
| 3308 | ); |
|
| 3309 | /* END: Use Case */ |
|
| 3310 | ||
| 3311 | $this->assertInstanceOf( |
|
| 3312 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Relation', |
|
| 3313 | $relation |
|
| 3314 | ); |
|
| 3315 | ||
| 3316 | return $this->contentService->loadRelations($draft->getVersionInfo()); |
|
| 3317 | } |
|
| 3318 | ||
| 3319 | /** |
|
| 3320 | * Test for the addRelation() method. |
|