Code Duplication    Length = 19-19 lines in 4 locations

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

@@ 124-142 (lines=19) @@
121
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
122
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfoByRemoteId
123
     */
124
    public function testLoadContentInfoByRemoteIdThrowsUnauthorizedException()
125
    {
126
        $repository = $this->getRepository();
127
128
        /* BEGIN: Use Case */
129
        // RemoteId of the "Anonymous User" in an eZ Publish demo installation
130
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
131
132
        $contentService = $repository->getContentService();
133
134
        $pseudoEditor = $this->createAnonymousWithEditorRole();
135
136
        // Set restricted editor user
137
        $repository->setCurrentUser($pseudoEditor);
138
139
        // This call will fail with a "UnauthorizedException"
140
        $contentService->loadContentInfoByRemoteId($anonymousRemoteId);
141
        /* END: Use Case */
142
    }
143
144
    /**
145
     * Test for the loadVersionInfo() method.
@@ 637-655 (lines=19) @@
634
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
635
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteId
636
     */
637
    public function testLoadContentByRemoteIdThrowsUnauthorizedException()
638
    {
639
        $repository = $this->getRepository();
640
641
        /* BEGIN: Use Case */
642
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
643
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
644
645
        $contentService = $repository->getContentService();
646
647
        $pseudoEditor = $this->createAnonymousWithEditorRole();
648
649
        // Set restricted editor user
650
        $repository->setCurrentUser($pseudoEditor);
651
652
        // This call will fail with a "UnauthorizedException"
653
        $contentService->loadContentByRemoteId($anonymousRemoteId);
654
        /* END: Use Case */
655
    }
656
657
    /**
658
     * Test for the loadContentByRemoteId() method.
@@ 664-682 (lines=19) @@
661
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
662
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithSecondParameter
663
     */
664
    public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithSecondParameter()
665
    {
666
        $repository = $this->getRepository();
667
668
        /* BEGIN: Use Case */
669
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
670
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
671
672
        $contentService = $repository->getContentService();
673
674
        $pseudoEditor = $this->createAnonymousWithEditorRole();
675
676
        // Set restricted editor user
677
        $repository->setCurrentUser($pseudoEditor);
678
679
        // This call will fail with a "UnauthorizedException"
680
        $contentService->loadContentByRemoteId($anonymousRemoteId, array('eng-US'));
681
        /* END: Use Case */
682
    }
683
684
    /**
685
     * Test for the loadContentByRemoteId() method.
@@ 691-709 (lines=19) @@
688
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
689
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentByRemoteIdWithThirdParameter
690
     */
691
    public function testLoadContentByRemoteIdThrowsUnauthorizedExceptionWithThirdParameter()
692
    {
693
        $repository = $this->getRepository();
694
695
        /* BEGIN: Use Case */
696
        // Remote id of the "Anonymous" user in a eZ Publish demo installation
697
        $anonymousRemoteId = 'faaeb9be3bd98ed09f606fc16d144eca';
698
699
        $contentService = $repository->getContentService();
700
701
        $pseudoEditor = $this->createAnonymousWithEditorRole();
702
703
        // Set restricted editor user
704
        $repository->setCurrentUser($pseudoEditor);
705
706
        // This call will fail with a "UnauthorizedException"
707
        $contentService->loadContentByRemoteId($anonymousRemoteId, array('eng-US'), 2);
708
        /* END: Use Case */
709
    }
710
711
    /**
712
     * Test for the updateContentMetadata() method.