Code Duplication    Length = 22-23 lines in 2 locations

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

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