Code Duplication    Length = 19-21 lines in 5 locations

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

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