Code Duplication    Length = 19-19 lines in 4 locations

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

@@ 167-185 (lines=19) @@
164
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
165
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId
166
     */
167
    public function testLoadContentInfoByRemoteIdThrowsUnauthorizedException()
168
    {
169
        $repository = $this->getRepository();
170
171
        /* BEGIN: Use Case */
172
        // RemoteId of the "Anonymous User" in an eZ Publish demo installation
173
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
174
175
        $contentService = $repository->getContentService();
176
177
        $pseudoEditor = $this->createAnonymousWithEditorRole();
178
179
        // Set restricted editor user
180
        $repository->setCurrentUser($pseudoEditor);
181
182
        // This call will fail with a "UnauthorizedException"
183
        $contentService->loadContentInfoByRemoteId($anonymousRemoteId);
184
        /* END: Use Case */
185
    }
186
187
    /**
188
     * Test for the loadVersionInfo() method.
@@ 680-698 (lines=19) @@
677
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
678
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId
679
     */
680
    public function testLoadContentByRemoteIdThrowsUnauthorizedException()
681
    {
682
        $repository = $this->getRepository();
683
684
        /* BEGIN: Use Case */
685
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
686
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
687
688
        $contentService = $repository->getContentService();
689
690
        $pseudoEditor = $this->createAnonymousWithEditorRole();
691
692
        // Set restricted editor user
693
        $repository->setCurrentUser($pseudoEditor);
694
695
        // This call will fail with a "UnauthorizedException"
696
        $contentService->loadContentByRemoteId($anonymousRemoteId);
697
        /* END: Use Case */
698
    }
699
700
    /**
701
     * Test for the loadContentByRemoteId() method.
@@ 707-725 (lines=19) @@
704
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
705
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithSecondParameter
706
     */
707
    public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithSecondParameter()
708
    {
709
        $repository = $this->getRepository();
710
711
        /* BEGIN: Use Case */
712
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
713
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
714
715
        $contentService = $repository->getContentService();
716
717
        $pseudoEditor = $this->createAnonymousWithEditorRole();
718
719
        // Set restricted editor user
720
        $repository->setCurrentUser($pseudoEditor);
721
722
        // This call will fail with a "UnauthorizedException"
723
        $contentService->loadContentByRemoteId($anonymousRemoteId, array('eng-US'));
724
        /* END: Use Case */
725
    }
726
727
    /**
728
     * Test for the loadContentByRemoteId() method.
@@ 734-752 (lines=19) @@
731
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
732
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithThirdParameter
733
     */
734
    public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithThirdParameter()
735
    {
736
        $repository = $this->getRepository();
737
738
        /* BEGIN: Use Case */
739
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
740
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
741
742
        $contentService = $repository->getContentService();
743
744
        $pseudoEditor = $this->createAnonymousWithEditorRole();
745
746
        // Set restricted editor user
747
        $repository->setCurrentUser($pseudoEditor);
748
749
        // This call will fail with a "UnauthorizedException"
750
        $contentService->loadContentByRemoteId($anonymousRemoteId, array('eng-US'), 2);
751
        /* END: Use Case */
752
    }
753
754
    /**
755
     * Test for the updateContentMetadata() method.