Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3377-3398 (lines=22) @@
3374
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3375
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3376
     */
3377
    public function testAddRelationThrowsBadStateException()
3378
    {
3379
        $repository = $this->getRepository();
3380
3381
        $contentService = $repository->getContentService();
3382
3383
        /* BEGIN: Use Case */
3384
        // RemoteId of the "Media" page of an eZ Publish demo installation
3385
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3386
3387
        $content = $this->createContentVersion1();
3388
3389
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3390
3391
        // This call will fail with a "BadStateException", because content is
3392
        // published and not a draft.
3393
        $contentService->addRelation(
3394
            $content->getVersionInfo(),
3395
            $media
3396
        );
3397
        /* END: Use Case */
3398
    }
3399
3400
    /**
3401
     * Test for the loadRelations() method.
@@ 3941-3963 (lines=23) @@
3938
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3939
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3940
     */
3941
    public function testDeleteRelationThrowsInvalidArgumentException()
3942
    {
3943
        $repository = $this->getRepository();
3944
3945
        $contentService = $repository->getContentService();
3946
3947
        /* BEGIN: Use Case */
3948
        // RemoteId of the "Media" page of an eZ Publish demo installation
3949
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3950
3951
        $draft = $this->createContentDraftVersion1();
3952
3953
        // Load the destination object
3954
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3955
3956
        // This call will fail with a "InvalidArgumentException", because no
3957
        // relation exists between $draft and $media.
3958
        $contentService->deleteRelation(
3959
            $draft->getVersionInfo(),
3960
            $media
3961
        );
3962
        /* END: Use Case */
3963
    }
3964
3965
    /**
3966
     * Test for the createContent() method.