Code Duplication    Length = 19-20 lines in 2 locations

eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php 2 locations

@@ 832-850 (lines=19) @@
829
     * @see \eZ\Publish\API\Repository\ContentService::loadRelations()
830
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations
831
     */
832
    public function testLoadRelationsThrowsUnauthorizedException()
833
    {
834
        $mediaEditor = $this->createMediaUserVersion1();
835
836
        $setupRemoteId = '241d538ce310074e602f29f49e44e938';
837
838
        $versionInfo = $this->contentService->loadVersionInfo(
839
            $this->contentService->loadContentInfoByRemoteId(
840
                $setupRemoteId
841
            )
842
        );
843
844
        $this->permissionResolver->setCurrentUserReference($mediaEditor);
845
846
        $this->expectException(UnauthorizedException::class);
847
        $this->expectExceptionMessageMatches('/\'read\' \'content\'/');
848
849
        $this->contentService->loadRelations($versionInfo);
850
    }
851
852
    /**
853
     * Test for the loadRelations() method.
@@ 898-917 (lines=20) @@
895
     * @see \eZ\Publish\API\Repository\ContentService::addRelation()
896
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
897
     */
898
    public function testAddRelationThrowsUnauthorizedException()
899
    {
900
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
901
902
        $draft = $this->createContentDraftVersion1();
903
904
        $versionInfo = $draft->getVersionInfo();
905
906
        $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId);
907
908
        $this->permissionResolver->setCurrentUserReference($this->anonymousUser);
909
910
        $this->expectException(UnauthorizedException::class);
911
        $this->expectExceptionMessageMatches('/\'versionread\' \'content\'/');
912
913
        $this->contentService->addRelation(
914
            $versionInfo,
915
            $media
916
        );
917
    }
918
919
    /**
920
     * Test for the deleteRelation() method.