Code Duplication    Length = 25-26 lines in 2 locations

eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php 1 location

@@ 994-1018 (lines=25) @@
991
     * @see \eZ\Publish\API\Repository\ContentService::deleteRelation()
992
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
993
     */
994
    public function testDeleteRelationThrowsUnauthorizedException()
995
    {
996
        /* BEGIN: Use Case */
997
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
998
        $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f';
999
1000
        $draft = $this->createContentDraftVersion1();
1001
1002
        $versionInfo = $draft->getVersionInfo();
1003
1004
        $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId);
1005
        $demoDesign = $this->contentService->loadContentInfoByRemoteId($demoDesignRemoteId);
1006
1007
        // Establish some relations
1008
        $this->contentService->addRelation($draft->getVersionInfo(), $media);
1009
        $this->contentService->addRelation($draft->getVersionInfo(), $demoDesign);
1010
1011
        $this->permissionResolver->setCurrentUserReference($this->anonymousUser);
1012
1013
        $this->expectException(UnauthorizedException::class);
1014
        $this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/');
1015
1016
        $this->contentService->deleteRelation($versionInfo, $media);
1017
        /* END: Use Case */
1018
    }
1019
1020
    /**
1021
     * Creates a pseudo editor with a limitation to objects in the "Media/Images"

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 1 location

@@ 3782-3807 (lines=26) @@
3779
     * @see \eZ\Publish\API\Repository\ContentService::deleteRelation()
3780
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadRelations
3781
     */
3782
    public function testDeleteRelation()
3783
    {
3784
        /* BEGIN: Use Case */
3785
        // Remote ids of the "Media" and the "Demo Design" page of a eZ Publish
3786
        // demo installation.
3787
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3788
        $demoDesignRemoteId = '8b8b22fe3c6061ed500fbd2b377b885f';
3789
3790
        $draft = $this->createContentDraftVersion1();
3791
3792
        $media = $this->contentService->loadContentInfoByRemoteId($mediaRemoteId);
3793
        $demoDesign = $this->contentService->loadContentInfoByRemoteId($demoDesignRemoteId);
3794
3795
        // Establish some relations
3796
        $this->contentService->addRelation($draft->getVersionInfo(), $media);
3797
        $this->contentService->addRelation($draft->getVersionInfo(), $demoDesign);
3798
3799
        // Delete one of the currently created relations
3800
        $this->contentService->deleteRelation($draft->getVersionInfo(), $media);
3801
3802
        // The relations array now contains only one element
3803
        $relations = $this->contentService->loadRelations($draft->getVersionInfo());
3804
        /* END: Use Case */
3805
3806
        $this->assertEquals(1, count($relations));
3807
    }
3808
3809
    /**
3810
     * Test for the deleteRelation() method.