Code Duplication    Length = 29-34 lines in 3 locations

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

@@ 4404-4432 (lines=29) @@
4401
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately
4402
     * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException
4403
     */
4404
    public function testCreateContentWithLocationCreateParameterInTransactionWithCommit()
4405
    {
4406
        $repository = $this->getRepository();
4407
4408
        $contentService = $repository->getContentService();
4409
4410
        /* BEGIN: Use Case */
4411
        // Start a transaction
4412
        $repository->beginTransaction();
4413
4414
        try {
4415
            $draft = $this->createContentDraftVersion1();
4416
4417
            $contentId = $draft->id;
4418
4419
            // Roleback the transaction
4420
            $repository->commit();
4421
        } catch (Exception $e) {
4422
            // Cleanup hanging transaction on error
4423
            $repository->rollback();
4424
            throw $e;
4425
        }
4426
4427
        // Load the new content object
4428
        $content = $contentService->loadContent($contentId);
4429
        /* END: Use Case */
4430
4431
        $this->assertEquals($contentId, $content->id);
4432
    }
4433
4434
    /**
4435
     * Test for the createContentDraft() method.

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

@@ 3553-3586 (lines=34) @@
3550
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup
3551
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup
3552
     */
3553
    public function testCreateContentTypeGroupInTransactionWithCommit()
3554
    {
3555
        $repository = $this->getRepository();
3556
3557
        /* BEGIN: Use Case */
3558
        $contentTypeService = $repository->getContentTypeService();
3559
3560
        // Get create struct and set language property
3561
        $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group');
3562
        /* @todo uncomment when support for multilingual names and descriptions is added
3563
        $groupCreate->mainLanguageCode = 'eng-GB';
3564
        */
3565
3566
        // Start a new transaction
3567
        $repository->beginTransaction();
3568
3569
        try {
3570
            // Create the new content type group
3571
            $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id;
3572
3573
            // Rollback all changes
3574
            $repository->commit();
3575
        } catch (Exception $e) {
3576
            // Cleanup hanging transaction on error
3577
            $repository->rollback();
3578
            throw $e;
3579
        }
3580
3581
        // Load created content type group
3582
        $group = $contentTypeService->loadContentTypeGroup($groupId);
3583
        /* END: Use Case */
3584
3585
        $this->assertEquals($groupId, $group->id);
3586
    }
3587
3588
    /**
3589
     * Test for the updateContentTypeGroup() method.
@@ 3940-3970 (lines=31) @@
3937
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier
3938
     * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException
3939
     */
3940
    public function testCopyContentTypeInTransactionWithCommit()
3941
    {
3942
        $repository = $this->getRepository();
3943
3944
        /* BEGIN: Use Case */
3945
        $contentTypeService = $repository->getContentTypeService();
3946
3947
        // Load content type to copy
3948
        $contentType = $contentTypeService->loadContentTypeByIdentifier('comment');
3949
3950
        // Start a new transaction
3951
        $repository->beginTransaction();
3952
3953
        try {
3954
            // Complete copy of the content type
3955
            $contentTypeId = $contentTypeService->copyContentType($contentType)->id;
3956
3957
            // Commit all changes
3958
            $repository->commit();
3959
        } catch (Exception $e) {
3960
            // Cleanup hanging transaction on error
3961
            $repository->rollback();
3962
            throw $e;
3963
        }
3964
3965
        // Load the new content type copy.
3966
        $copiedContentType = $contentTypeService->loadContentType($contentTypeId);
3967
        /* END: Use Case */
3968
3969
        $this->assertEquals($contentTypeId, $copiedContentType->id);
3970
    }
3971
3972
    /**
3973
     * Test for the deleteContentType() method.