Code Duplication    Length = 19-21 lines in 5 locations

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 3 locations

@@ 488-506 (lines=19) @@
485
     * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo()
486
     * @group user
487
     */
488
    public function testLoadContentInfo()
489
    {
490
        $repository = $this->getRepository();
491
492
        $mediaFolderId = $this->generateId('object', 41);
493
        /* BEGIN: Use Case */
494
        $contentService = $repository->getContentService();
495
496
        // Load the ContentInfo for "Media" folder
497
        $contentInfo = $contentService->loadContentInfo($mediaFolderId);
498
        /* END: Use Case */
499
500
        $this->assertInstanceOf(
501
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo',
502
            $contentInfo
503
        );
504
505
        return $contentInfo;
506
    }
507
508
    /**
509
     * Test for the returned value of the loadContentInfo() method.
@@ 649-669 (lines=21) @@
646
     *
647
     * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById()
648
     */
649
    public function testLoadVersionInfoById()
650
    {
651
        $repository = $this->getRepository();
652
653
        $mediaFolderId = $this->generateId('object', 41);
654
        /* BEGIN: Use Case */
655
        // $mediaFolderId contains the ID of the "Media" folder
656
657
        $contentService = $repository->getContentService();
658
659
        // Load the VersionInfo for "Media" folder
660
        $versionInfo = $contentService->loadVersionInfoById($mediaFolderId);
661
        /* END: Use Case */
662
663
        $this->assertInstanceOf(
664
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo',
665
            $versionInfo
666
        );
667
668
        return $versionInfo;
669
    }
670
671
    /**
672
     * Test for the returned value of the loadVersionInfoById() method.
@@ 793-811 (lines=19) @@
790
     * @group user
791
     * @group field-type
792
     */
793
    public function testLoadContent()
794
    {
795
        $repository = $this->getRepository();
796
797
        $mediaFolderId = $this->generateId('object', 41);
798
        /* BEGIN: Use Case */
799
        // $mediaFolderId contains the ID of the "Media" folder
800
801
        $contentService = $repository->getContentService();
802
803
        // Load the Content for "Media" folder, any language and current version
804
        $content = $contentService->loadContent($mediaFolderId);
805
        /* END: Use Case */
806
807
        $this->assertInstanceOf(
808
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',
809
            $content
810
        );
811
    }
812
813
    /**
814
     * Test for the loadContent() method.

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

@@ 213-232 (lines=20) @@
210
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
211
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoById
212
     */
213
    public function testLoadVersionInfoByIdThrowsUnauthorizedException()
214
    {
215
        $repository = $this->getRepository();
216
217
        $anonymousUserId = $this->generateId('user', 10);
218
        /* BEGIN: Use Case */
219
        // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish
220
        // demo installation
221
222
        $contentService = $repository->getContentService();
223
224
        $pseudoEditor = $this->createAnonymousWithEditorRole();
225
226
        // Set restricted editor user
227
        $repository->setCurrentUser($pseudoEditor);
228
229
        // This call will fail with a "UnauthorizedException"
230
        $contentService->loadVersionInfoById($anonymousUserId);
231
        /* END: Use Case */
232
    }
233
234
    /**
235
     * Test for the loadVersionInfoById() method.
@@ 241-260 (lines=20) @@
238
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
239
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadVersionInfoByIdWithSecondParameter
240
     */
241
    public function testLoadVersionInfoByIdThrowsUnauthorizedExceptionWithSecondParameter()
242
    {
243
        $repository = $this->getRepository();
244
245
        $anonymousUserId = $this->generateId('user', 10);
246
        /* BEGIN: Use Case */
247
        // $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish
248
        // demo installation
249
250
        $contentService = $repository->getContentService();
251
252
        $pseudoEditor = $this->createAnonymousWithEditorRole();
253
254
        // Set restricted editor user
255
        $repository->setCurrentUser($pseudoEditor);
256
257
        // This call will fail with a "UnauthorizedException"
258
        $contentService->loadVersionInfoById($anonymousUserId, 2);
259
        /* END: Use Case */
260
    }
261
262
    /**
263
     * Test for the loadVersionInfoById() method.