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

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