Code Duplication    Length = 13-23 lines in 3 locations

eZ/Publish/Core/Repository/Tests/Service/Integration/ContentBase.php 1 location

@@ 2420-2432 (lines=13) @@
2417
     * @covers \eZ\Publish\Core\Repository\ContentService::addRelation
2418
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
2419
     */
2420
    public function testAddRelationThrowsBadStateException()
2421
    {
2422
        $contentService = $this->repository->getContentService();
2423
        list($contentDraft, $contentType) = $this->createTestContent();
2424
        $publishedContent = $contentService->publishVersion($contentDraft->versionInfo);
2425
2426
        $mediaContentInfo = $contentService->loadContentInfoByRemoteId('a6e35cbcb7cd6ae4b691f3eee30cd262');
2427
2428
        $contentService->addRelation(
2429
            $publishedContent->getVersionInfo(),
2430
            $mediaContentInfo
2431
        );
2432
    }
2433
2434
    /**
2435
     * Test for the deleteRelation() method.

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

@@ 3013-3034 (lines=22) @@
3010
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
3011
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testAddRelation
3012
     */
3013
    public function testAddRelationThrowsBadStateException()
3014
    {
3015
        $repository = $this->getRepository();
3016
3017
        $contentService = $repository->getContentService();
3018
3019
        /* BEGIN: Use Case */
3020
        // RemoteId of the "Media" page of an eZ Publish demo installation
3021
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3022
3023
        $content = $this->createContentVersion1();
3024
3025
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3026
3027
        // This call will fail with a "BadStateException", because content is
3028
        // published and not a draft.
3029
        $contentService->addRelation(
3030
            $content->getVersionInfo(),
3031
            $media
3032
        );
3033
        /* END: Use Case */
3034
    }
3035
3036
    /**
3037
     * Test for the loadRelations() method.
@@ 3577-3599 (lines=23) @@
3574
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
3575
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteRelation
3576
     */
3577
    public function testDeleteRelationThrowsInvalidArgumentException()
3578
    {
3579
        $repository = $this->getRepository();
3580
3581
        $contentService = $repository->getContentService();
3582
3583
        /* BEGIN: Use Case */
3584
        // RemoteId of the "Media" page of an eZ Publish demo installation
3585
        $mediaRemoteId = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
3586
3587
        $draft = $this->createContentDraftVersion1();
3588
3589
        // Load the destination object
3590
        $media = $contentService->loadContentInfoByRemoteId($mediaRemoteId);
3591
3592
        // This call will fail with a "InvalidArgumentException", because no
3593
        // relation exists between $draft and $media.
3594
        $contentService->deleteRelation(
3595
            $draft->getVersionInfo(),
3596
            $media
3597
        );
3598
        /* END: Use Case */
3599
    }
3600
3601
    /**
3602
     * Test for the createContent() method.