Code Duplication    Length = 17-20 lines in 5 locations

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

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

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

@@ 481-497 (lines=17) @@
478
     * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo()
479
     * @group user
480
     */
481
    public function testLoadContentInfo()
482
    {
483
        $repository = $this->getRepository();
484
485
        $mediaFolderId = $this->generateId('object', 41);
486
        /* BEGIN: Use Case */
487
        $contentService = $repository->getContentService();
488
489
        // Load the ContentInfo for "Media" folder
490
        $contentInfo = $contentService->loadContentInfo($mediaFolderId);
491
        /* END: Use Case */
492
493
        $this->assertInstanceOf(
494
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo',
495
            $contentInfo
496
        );
497
    }
498
499
    /**
500
     * Test for the loadContentInfo() method.
@@ 592-610 (lines=19) @@
589
     *
590
     * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById()
591
     */
592
    public function testLoadVersionInfoById()
593
    {
594
        $repository = $this->getRepository();
595
596
        $mediaFolderId = $this->generateId('object', 41);
597
        /* BEGIN: Use Case */
598
        // $mediaFolderId contains the ID of the "Media" folder
599
600
        $contentService = $repository->getContentService();
601
602
        // Load the VersionInfo for "Media" folder
603
        $versionInfo = $contentService->loadVersionInfoById($mediaFolderId);
604
        /* END: Use Case */
605
606
        $this->assertInstanceOf(
607
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo',
608
            $versionInfo
609
        );
610
    }
611
612
    /**
613
     * Test for the loadVersionInfoById() method.
@@ 700-718 (lines=19) @@
697
     * @group user
698
     * @group field-type
699
     */
700
    public function testLoadContent()
701
    {
702
        $repository = $this->getRepository();
703
704
        $mediaFolderId = $this->generateId('object', 41);
705
        /* BEGIN: Use Case */
706
        // $mediaFolderId contains the ID of the "Media" folder
707
708
        $contentService = $repository->getContentService();
709
710
        // Load the Content for "Media" folder, any language and current version
711
        $content = $contentService->loadContent($mediaFolderId);
712
        /* END: Use Case */
713
714
        $this->assertInstanceOf(
715
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',
716
            $content
717
        );
718
    }
719
720
    /**
721
     * Test for the loadContent() method.