| @@ 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. |
|
| @@ 3801-3829 (lines=29) @@ | ||
| 3798 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 3799 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 3800 | */ |
|
| 3801 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 3802 | { |
|
| 3803 | $repository = $this->getRepository(); |
|
| 3804 | ||
| 3805 | $contentService = $repository->getContentService(); |
|
| 3806 | ||
| 3807 | /* BEGIN: Use Case */ |
|
| 3808 | // Start a transaction |
|
| 3809 | $repository->beginTransaction(); |
|
| 3810 | ||
| 3811 | try { |
|
| 3812 | $draft = $this->createContentDraftVersion1(); |
|
| 3813 | ||
| 3814 | $contentId = $draft->id; |
|
| 3815 | ||
| 3816 | // Roleback the transaction |
|
| 3817 | $repository->commit(); |
|
| 3818 | } catch (Exception $e) { |
|
| 3819 | // Cleanup hanging transaction on error |
|
| 3820 | $repository->rollback(); |
|
| 3821 | throw $e; |
|
| 3822 | } |
|
| 3823 | ||
| 3824 | // Load the new content object |
|
| 3825 | $content = $contentService->loadContent($contentId); |
|
| 3826 | /* END: Use Case */ |
|
| 3827 | ||
| 3828 | $this->assertEquals($contentId, $content->id); |
|
| 3829 | } |
|
| 3830 | ||
| 3831 | /** |
|
| 3832 | * Test for the createContentDraft() method. |
|