Code Duplication    Length = 29-34 lines in 3 locations

eZ/Publish/API/Repository/Tests/ContentServiceTest.php 1 location

@@ 3746-3774 (lines=29) @@
3743
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately
3744
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException
3745
     */
3746
    public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()
3747
    {
3748
        $repository = $this->getRepository();
3749
3750
        $contentService = $repository->getContentService();
3751
3752
        /* BEGIN: Use Case */
3753
        // Start a transaction
3754
        $repository->beginTransaction();
3755
3756
        try {
3757
            $draft = $this->createContentDraftVersion1();
3758
3759
            $contentId = $draft->id;
3760
3761
            // Roleback the transaction
3762
            $repository->commit();
3763
        } catch (Exception $e) {
3764
            // Cleanup hanging transaction on error
3765
            $repository->rollback();
3766
            throw $e;
3767
        }
3768
3769
        // Load the new content object
3770
        $content = $contentService->loadContent($contentId);
3771
        /* END: Use Case */
3772
3773
        $this->assertEquals($contentId, $content->id);
3774
    }
3775
3776
    /**
3777
     * Test for the createContentDraft() method.

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

@@ 3016-3049 (lines=34) @@
3013
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup
3014
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup
3015
     */
3016
    public function testCreateContentTypeGroupInTransactionWithCommit()
3017
    {
3018
        $repository = $this->getRepository();
3019
3020
        /* BEGIN: Use Case */
3021
        $contentTypeService = $repository->getContentTypeService();
3022
3023
        // Get create struct and set language property
3024
        $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group');
3025
        /* @todo uncomment when support for multilingual names and descriptions is added
3026
        $groupCreate->mainLanguageCode = 'eng-GB';
3027
        */
3028
3029
        // Start a new transaction
3030
        $repository->beginTransaction();
3031
3032
        try {
3033
            // Create the new content type group
3034
            $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id;
3035
3036
            // Rollback all changes
3037
            $repository->commit();
3038
        } catch (Exception $e) {
3039
            // Cleanup hanging transaction on error
3040
            $repository->rollback();
3041
            throw $e;
3042
        }
3043
3044
        // Load created content type group
3045
        $group = $contentTypeService->loadContentTypeGroup($groupId);
3046
        /* END: Use Case */
3047
3048
        $this->assertEquals($groupId, $group->id);
3049
    }
3050
3051
    /**
3052
     * Test for the updateContentTypeGroup() method.
@@ 3403-3433 (lines=31) @@
3400
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier
3401
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException
3402
     */
3403
    public function testCopyContentTypeInTransactionWithCommit()
3404
    {
3405
        $repository = $this->getRepository();
3406
3407
        /* BEGIN: Use Case */
3408
        $contentTypeService = $repository->getContentTypeService();
3409
3410
        // Load content type to copy
3411
        $contentType = $contentTypeService->loadContentTypeByIdentifier('comment');
3412
3413
        // Start a new transaction
3414
        $repository->beginTransaction();
3415
3416
        try {
3417
            // Complete copy of the content type
3418
            $contentTypeId = $contentTypeService->copyContentType($contentType)->id;
3419
3420
            // Commit all changes
3421
            $repository->commit();
3422
        } catch (Exception $e) {
3423
            // Cleanup hanging transaction on error
3424
            $repository->rollback();
3425
            throw $e;
3426
        }
3427
3428
        // Load the new content type copy.
3429
        $copiedContentType = $contentTypeService->loadContentType($contentTypeId);
3430
        /* END: Use Case */
3431
3432
        $this->assertEquals($contentTypeId, $copiedContentType->id);
3433
    }
3434
3435
    /**
3436
     * Test for the deleteContentType() method.