Code Duplication    Length = 29-34 lines in 3 locations

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.

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

@@ 3856-3884 (lines=29) @@
3853
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately
3854
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException
3855
     */
3856
    public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()
3857
    {
3858
        $repository = $this->getRepository();
3859
3860
        $contentService = $repository->getContentService();
3861
3862
        /* BEGIN: Use Case */
3863
        // Start a transaction
3864
        $repository->beginTransaction();
3865
3866
        try {
3867
            $draft = $this->createContentDraftVersion1();
3868
3869
            $contentId = $draft->id;
3870
3871
            // Roleback the transaction
3872
            $repository->commit();
3873
        } catch (Exception $e) {
3874
            // Cleanup hanging transaction on error
3875
            $repository->rollback();
3876
            throw $e;
3877
        }
3878
3879
        // Load the new content object
3880
        $content = $contentService->loadContent($contentId);
3881
        /* END: Use Case */
3882
3883
        $this->assertEquals($contentId, $content->id);
3884
    }
3885
3886
    /**
3887
     * Test for the createContentDraft() method.