Code Duplication    Length = 17-20 lines in 5 locations

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.

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

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