Code Duplication    Length = 22-23 lines in 2 locations

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

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