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