Code Duplication    Length = 19-19 lines in 4 locations

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

@@ 149-167 (lines=19) @@
146
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
147
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId
148
     */
149
    public function testLoadContentInfoByRemoteIdThrowsUnauthorizedException()
150
    {
151
        $repository = $this->getRepository();
152
153
        /* BEGIN: Use Case */
154
        // RemoteId of the "Anonymous User" in an eZ Publish demo installation
155
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
156
157
        $contentService = $repository->getContentService();
158
159
        $pseudoEditor = $this->createAnonymousWithEditorRole();
160
161
        // Set restricted editor user
162
        $repository->setCurrentUser($pseudoEditor);
163
164
        // This call will fail with a "UnauthorizedException"
165
        $contentService->loadContentInfoByRemoteId($anonymousRemoteId);
166
        /* END: Use Case */
167
    }
168
169
    /**
170
     * Test for the loadVersionInfo() method.
@@ 662-680 (lines=19) @@
659
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
660
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId
661
     */
662
    public function testLoadContentByRemoteIdThrowsUnauthorizedException()
663
    {
664
        $repository = $this->getRepository();
665
666
        /* BEGIN: Use Case */
667
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
668
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
669
670
        $contentService = $repository->getContentService();
671
672
        $pseudoEditor = $this->createAnonymousWithEditorRole();
673
674
        // Set restricted editor user
675
        $repository->setCurrentUser($pseudoEditor);
676
677
        // This call will fail with a "UnauthorizedException"
678
        $contentService->loadContentByRemoteId($anonymousRemoteId);
679
        /* END: Use Case */
680
    }
681
682
    /**
683
     * Test for the loadContentByRemoteId() method.
@@ 689-707 (lines=19) @@
686
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
687
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithSecondParameter
688
     */
689
    public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithSecondParameter()
690
    {
691
        $repository = $this->getRepository();
692
693
        /* BEGIN: Use Case */
694
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
695
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
696
697
        $contentService = $repository->getContentService();
698
699
        $pseudoEditor = $this->createAnonymousWithEditorRole();
700
701
        // Set restricted editor user
702
        $repository->setCurrentUser($pseudoEditor);
703
704
        // This call will fail with a "UnauthorizedException"
705
        $contentService->loadContentByRemoteId($anonymousRemoteId, array('eng-US'));
706
        /* END: Use Case */
707
    }
708
709
    /**
710
     * Test for the loadContentByRemoteId() method.
@@ 716-734 (lines=19) @@
713
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
714
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithThirdParameter
715
     */
716
    public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithThirdParameter()
717
    {
718
        $repository = $this->getRepository();
719
720
        /* BEGIN: Use Case */
721
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
722
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
723
724
        $contentService = $repository->getContentService();
725
726
        $pseudoEditor = $this->createAnonymousWithEditorRole();
727
728
        // Set restricted editor user
729
        $repository->setCurrentUser($pseudoEditor);
730
731
        // This call will fail with a "UnauthorizedException"
732
        $contentService->loadContentByRemoteId($anonymousRemoteId, array('eng-US'), 2);
733
        /* END: Use Case */
734
    }
735
736
    /**
737
     * Test for the updateContentMetadata() method.