Code Duplication    Length = 29-34 lines in 3 locations

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

@@ 4074-4102 (lines=29) @@
4071
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately
4072
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException
4073
     */
4074
    public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()
4075
    {
4076
        $repository = $this->getRepository();
4077
4078
        $contentService = $repository->getContentService();
4079
4080
        /* BEGIN: Use Case */
4081
        // Start a transaction
4082
        $repository->beginTransaction();
4083
4084
        try {
4085
            $draft = $this->createContentDraftVersion1();
4086
4087
            $contentId = $draft->id;
4088
4089
            // Roleback the transaction
4090
            $repository->commit();
4091
        } catch (Exception $e) {
4092
            // Cleanup hanging transaction on error
4093
            $repository->rollback();
4094
            throw $e;
4095
        }
4096
4097
        // Load the new content object
4098
        $content = $contentService->loadContent($contentId);
4099
        /* END: Use Case */
4100
4101
        $this->assertEquals($contentId, $content->id);
4102
    }
4103
4104
    /**
4105
     * Test for the createContentDraft() method.

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

@@ 3311-3344 (lines=34) @@
3308
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup
3309
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup
3310
     */
3311
    public function testCreateContentTypeGroupInTransactionWithCommit()
3312
    {
3313
        $repository = $this->getRepository();
3314
3315
        /* BEGIN: Use Case */
3316
        $contentTypeService = $repository->getContentTypeService();
3317
3318
        // Get create struct and set language property
3319
        $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group');
3320
        /* @todo uncomment when support for multilingual names and descriptions is added
3321
        $groupCreate->mainLanguageCode = 'eng-GB';
3322
        */
3323
3324
        // Start a new transaction
3325
        $repository->beginTransaction();
3326
3327
        try {
3328
            // Create the new content type group
3329
            $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id;
3330
3331
            // Rollback all changes
3332
            $repository->commit();
3333
        } catch (Exception $e) {
3334
            // Cleanup hanging transaction on error
3335
            $repository->rollback();
3336
            throw $e;
3337
        }
3338
3339
        // Load created content type group
3340
        $group = $contentTypeService->loadContentTypeGroup($groupId);
3341
        /* END: Use Case */
3342
3343
        $this->assertEquals($groupId, $group->id);
3344
    }
3345
3346
    /**
3347
     * Test for the updateContentTypeGroup() method.
@@ 3698-3728 (lines=31) @@
3695
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier
3696
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException
3697
     */
3698
    public function testCopyContentTypeInTransactionWithCommit()
3699
    {
3700
        $repository = $this->getRepository();
3701
3702
        /* BEGIN: Use Case */
3703
        $contentTypeService = $repository->getContentTypeService();
3704
3705
        // Load content type to copy
3706
        $contentType = $contentTypeService->loadContentTypeByIdentifier('comment');
3707
3708
        // Start a new transaction
3709
        $repository->beginTransaction();
3710
3711
        try {
3712
            // Complete copy of the content type
3713
            $contentTypeId = $contentTypeService->copyContentType($contentType)->id;
3714
3715
            // Commit all changes
3716
            $repository->commit();
3717
        } catch (Exception $e) {
3718
            // Cleanup hanging transaction on error
3719
            $repository->rollback();
3720
            throw $e;
3721
        }
3722
3723
        // Load the new content type copy.
3724
        $copiedContentType = $contentTypeService->loadContentType($contentTypeId);
3725
        /* END: Use Case */
3726
3727
        $this->assertEquals($contentTypeId, $copiedContentType->id);
3728
    }
3729
3730
    /**
3731
     * Test for the deleteContentType() method.