Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3337-3358 (lines=22) @@
3334
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3335
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3336
     */
3337
    public function testAddRelationThrowsBadStateException()
3338
    {
3339
        $repository = $this->getRepository();
3340
3341
        $contentService = $repository->getContentService();
3342
3343
        /* BEGIN: Use Case */
3344
        // RemoteId of the "Media" page of an eZ Publish demo installation
3345
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3346
3347
        $content = $this->createContentVersion1();
3348
3349
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3350
3351
        // This call will fail with a "BadStateException", because content is
3352
        // published and not a draft.
3353
        $contentService->addRelation(
3354
            $content->getVersionInfo(),
3355
            $media
3356
        );
3357
        /* END: Use Case */
3358
    }
3359
3360
    /**
3361
     * Test for the loadRelations() method.
@@ 3901-3923 (lines=23) @@
3898
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3899
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3900
     */
3901
    public function testDeleteRelationThrowsInvalidArgumentException()
3902
    {
3903
        $repository = $this->getRepository();
3904
3905
        $contentService = $repository->getContentService();
3906
3907
        /* BEGIN: Use Case */
3908
        // RemoteId of the "Media" page of an eZ Publish demo installation
3909
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3910
3911
        $draft = $this->createContentDraftVersion1();
3912
3913
        // Load the destination object
3914
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3915
3916
        // This call will fail with a "InvalidArgumentException", because no
3917
        // relation exists between $draft and $media.
3918
        $contentService->deleteRelation(
3919
            $draft->getVersionInfo(),
3920
            $media
3921
        );
3922
        /* END: Use Case */
3923
    }
3924
3925
    /**
3926
     * Test for the createContent() method.