Code Duplication    Length = 17-20 lines in 5 locations

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

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

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

@@ 475-491 (lines=17) @@
472
     * @see \eZ\Publish\API\Repository\ContentService::loadContentInfo()
473
     * @group user
474
     */
475
    public function testLoadContentInfo()
476
    {
477
        $repository = $this->getRepository();
478
479
        $mediaFolderId = $this->generateId('object', 41);
480
        /* BEGIN: Use Case */
481
        $contentService = $repository->getContentService();
482
483
        // Load the ContentInfo for "Media" folder
484
        $contentInfo = $contentService->loadContentInfo($mediaFolderId);
485
        /* END: Use Case */
486
487
        $this->assertInstanceOf(
488
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo',
489
            $contentInfo
490
        );
491
    }
492
493
    /**
494
     * Test for the loadContentInfo() method.
@@ 586-604 (lines=19) @@
583
     *
584
     * @see \eZ\Publish\API\Repository\ContentService::loadVersionInfoById()
585
     */
586
    public function testLoadVersionInfoById()
587
    {
588
        $repository = $this->getRepository();
589
590
        $mediaFolderId = $this->generateId('object', 41);
591
        /* BEGIN: Use Case */
592
        // $mediaFolderId contains the ID of the "Media" folder
593
594
        $contentService = $repository->getContentService();
595
596
        // Load the VersionInfo for "Media" folder
597
        $versionInfo = $contentService->loadVersionInfoById($mediaFolderId);
598
        /* END: Use Case */
599
600
        $this->assertInstanceOf(
601
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo',
602
            $versionInfo
603
        );
604
    }
605
606
    /**
607
     * Test for the loadVersionInfoById() method.
@@ 694-712 (lines=19) @@
691
     * @group user
692
     * @group field-type
693
     */
694
    public function testLoadContent()
695
    {
696
        $repository = $this->getRepository();
697
698
        $mediaFolderId = $this->generateId('object', 41);
699
        /* BEGIN: Use Case */
700
        // $mediaFolderId contains the ID of the "Media" folder
701
702
        $contentService = $repository->getContentService();
703
704
        // Load the Content for "Media" folder, any language and current version
705
        $content = $contentService->loadContent($mediaFolderId);
706
        /* END: Use Case */
707
708
        $this->assertInstanceOf(
709
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content',
710
            $content
711
        );
712
    }
713
714
    /**
715
     * Test for the loadContent() method.