Code Duplication    Length = 13-23 lines in 3 locations

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

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

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

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