Code Duplication    Length = 22-23 lines in 2 locations

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

@@ 3637-3658 (lines=22) @@
3634
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3635
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3636
     */
3637
    public function testAddRelationThrowsBadStateException()
3638
    {
3639
        $repository = $this->getRepository();
3640
3641
        $contentService = $repository->getContentService();
3642
3643
        /* BEGIN: Use Case */
3644
        // RemoteId of the "Media" page of an eZ Publish demo installation
3645
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3646
3647
        $content = $this->createContentVersion1();
3648
3649
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3650
3651
        // This call will fail with a "BadStateException", because content is
3652
        // published and not a draft.
3653
        $contentService->addRelation(
3654
            $content->getVersionInfo(),
3655
            $media
3656
        );
3657
        /* END: Use Case */
3658
    }
3659
3660
    /**
3661
     * Test for the loadRelations() method.
@@ 4201-4223 (lines=23) @@
4198
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
4199
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
4200
     */
4201
    public function testDeleteRelationThrowsInvalidArgumentException()
4202
    {
4203
        $repository = $this->getRepository();
4204
4205
        $contentService = $repository->getContentService();
4206
4207
        /* BEGIN: Use Case */
4208
        // RemoteId of the "Media" page of an eZ Publish demo installation
4209
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
4210
4211
        $draft = $this->createContentDraftVersion1();
4212
4213
        // Load the destination object
4214
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
4215
4216
        // This call will fail with a "InvalidArgumentException", because no
4217
        // relation exists between $draft and $media.
4218
        $contentService->deleteRelation(
4219
            $draft->getVersionInfo(),
4220
            $media
4221
        );
4222
        /* END: Use Case */
4223
    }
4224
4225
    /**
4226
     * Test for the createContent() method.