Code Duplication    Length = 22-23 lines in 2 locations

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

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