Code Duplication    Length = 19-19 lines in 4 locations

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

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