Code Duplication    Length = 29-34 lines in 3 locations

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

@@ 4164-4192 (lines=29) @@
4161
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately
4162
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException
4163
     */
4164
    public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()
4165
    {
4166
        $repository = $this->getRepository();
4167
4168
        $contentService = $repository->getContentService();
4169
4170
        /* BEGIN: Use Case */
4171
        // Start a transaction
4172
        $repository->beginTransaction();
4173
4174
        try {
4175
            $draft = $this->createContentDraftVersion1();
4176
4177
            $contentId = $draft->id;
4178
4179
            // Roleback the transaction
4180
            $repository->commit();
4181
        } catch (Exception $e) {
4182
            // Cleanup hanging transaction on error
4183
            $repository->rollback();
4184
            throw $e;
4185
        }
4186
4187
        // Load the new content object
4188
        $content = $contentService->loadContent($contentId);
4189
        /* END: Use Case */
4190
4191
        $this->assertEquals($contentId, $content->id);
4192
    }
4193
4194
    /**
4195
     * Test for the createContentDraft() method.

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

@@ 3408-3441 (lines=34) @@
3405
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup
3406
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup
3407
     */
3408
    public function testCreateContentTypeGroupInTransactionWithCommit()
3409
    {
3410
        $repository = $this->getRepository();
3411
3412
        /* BEGIN: Use Case */
3413
        $contentTypeService = $repository->getContentTypeService();
3414
3415
        // Get create struct and set language property
3416
        $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group');
3417
        /* @todo uncomment when support for multilingual names and descriptions is added
3418
        $groupCreate->mainLanguageCode = 'eng-GB';
3419
        */
3420
3421
        // Start a new transaction
3422
        $repository->beginTransaction();
3423
3424
        try {
3425
            // Create the new content type group
3426
            $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id;
3427
3428
            // Rollback all changes
3429
            $repository->commit();
3430
        } catch (Exception $e) {
3431
            // Cleanup hanging transaction on error
3432
            $repository->rollback();
3433
            throw $e;
3434
        }
3435
3436
        // Load created content type group
3437
        $group = $contentTypeService->loadContentTypeGroup($groupId);
3438
        /* END: Use Case */
3439
3440
        $this->assertEquals($groupId, $group->id);
3441
    }
3442
3443
    /**
3444
     * Test for the updateContentTypeGroup() method.
@@ 3795-3825 (lines=31) @@
3792
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier
3793
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException
3794
     */
3795
    public function testCopyContentTypeInTransactionWithCommit()
3796
    {
3797
        $repository = $this->getRepository();
3798
3799
        /* BEGIN: Use Case */
3800
        $contentTypeService = $repository->getContentTypeService();
3801
3802
        // Load content type to copy
3803
        $contentType = $contentTypeService->loadContentTypeByIdentifier('comment');
3804
3805
        // Start a new transaction
3806
        $repository->beginTransaction();
3807
3808
        try {
3809
            // Complete copy of the content type
3810
            $contentTypeId = $contentTypeService->copyContentType($contentType)->id;
3811
3812
            // Commit all changes
3813
            $repository->commit();
3814
        } catch (Exception $e) {
3815
            // Cleanup hanging transaction on error
3816
            $repository->rollback();
3817
            throw $e;
3818
        }
3819
3820
        // Load the new content type copy.
3821
        $copiedContentType = $contentTypeService->loadContentType($contentTypeId);
3822
        /* END: Use Case */
3823
3824
        $this->assertEquals($contentTypeId, $copiedContentType->id);
3825
    }
3826
3827
    /**
3828
     * Test for the deleteContentType() method.