Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3409-3430 (lines=22) @@
3406
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3407
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3408
     */
3409
    public function testAddRelationThrowsBadStateException()
3410
    {
3411
        $repository = $this->getRepository();
3412
3413
        $contentService = $repository->getContentService();
3414
3415
        /* BEGIN: Use Case */
3416
        // RemoteId of the "Media" page of an eZ Publish demo installation
3417
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3418
3419
        $content = $this->createContentVersion1();
3420
3421
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3422
3423
        // This call will fail with a "BadStateException", because content is
3424
        // published and not a draft.
3425
        $contentService->addRelation(
3426
            $content->getVersionInfo(),
3427
            $media
3428
        );
3429
        /* END: Use Case */
3430
    }
3431
3432
    /**
3433
     * Test for the loadRelations() method.
@@ 3973-3995 (lines=23) @@
3970
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3971
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3972
     */
3973
    public function testDeleteRelationThrowsInvalidArgumentException()
3974
    {
3975
        $repository = $this->getRepository();
3976
3977
        $contentService = $repository->getContentService();
3978
3979
        /* BEGIN: Use Case */
3980
        // RemoteId of the "Media" page of an eZ Publish demo installation
3981
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3982
3983
        $draft = $this->createContentDraftVersion1();
3984
3985
        // Load the destination object
3986
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3987
3988
        // This call will fail with a "InvalidArgumentException", because no
3989
        // relation exists between $draft and $media.
3990
        $contentService->deleteRelation(
3991
            $draft->getVersionInfo(),
3992
            $media
3993
        );
3994
        /* END: Use Case */
3995
    }
3996
3997
    /**
3998
     * Test for the createContent() method.