| @@ 3362-3395 (lines=34) @@ | ||
| 3359 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3360 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3361 | */ |
|
| 3362 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3363 | { |
|
| 3364 | $repository = $this->getRepository(); |
|
| 3365 | ||
| 3366 | /* BEGIN: Use Case */ |
|
| 3367 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3368 | ||
| 3369 | // Get create struct and set language property |
|
| 3370 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3371 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3372 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3373 | */ |
|
| 3374 | ||
| 3375 | // Start a new transaction |
|
| 3376 | $repository->beginTransaction(); |
|
| 3377 | ||
| 3378 | try { |
|
| 3379 | // Create the new content type group |
|
| 3380 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3381 | ||
| 3382 | // Rollback all changes |
|
| 3383 | $repository->commit(); |
|
| 3384 | } catch (Exception $e) { |
|
| 3385 | // Cleanup hanging transaction on error |
|
| 3386 | $repository->rollback(); |
|
| 3387 | throw $e; |
|
| 3388 | } |
|
| 3389 | ||
| 3390 | // Load created content type group |
|
| 3391 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3392 | /* END: Use Case */ |
|
| 3393 | ||
| 3394 | $this->assertEquals($groupId, $group->id); |
|
| 3395 | } |
|
| 3396 | ||
| 3397 | /** |
|
| 3398 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3749-3779 (lines=31) @@ | ||
| 3746 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3747 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3748 | */ |
|
| 3749 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3750 | { |
|
| 3751 | $repository = $this->getRepository(); |
|
| 3752 | ||
| 3753 | /* BEGIN: Use Case */ |
|
| 3754 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3755 | ||
| 3756 | // Load content type to copy |
|
| 3757 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3758 | ||
| 3759 | // Start a new transaction |
|
| 3760 | $repository->beginTransaction(); |
|
| 3761 | ||
| 3762 | try { |
|
| 3763 | // Complete copy of the content type |
|
| 3764 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3765 | ||
| 3766 | // Commit all changes |
|
| 3767 | $repository->commit(); |
|
| 3768 | } catch (Exception $e) { |
|
| 3769 | // Cleanup hanging transaction on error |
|
| 3770 | $repository->rollback(); |
|
| 3771 | throw $e; |
|
| 3772 | } |
|
| 3773 | ||
| 3774 | // Load the new content type copy. |
|
| 3775 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3776 | /* END: Use Case */ |
|
| 3777 | ||
| 3778 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3779 | } |
|
| 3780 | ||
| 3781 | /** |
|
| 3782 | * Test for the deleteContentType() method. |
|
| @@ 4149-4177 (lines=29) @@ | ||
| 4146 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4147 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4148 | */ |
|
| 4149 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4150 | { |
|
| 4151 | $repository = $this->getRepository(); |
|
| 4152 | ||
| 4153 | $contentService = $repository->getContentService(); |
|
| 4154 | ||
| 4155 | /* BEGIN: Use Case */ |
|
| 4156 | // Start a transaction |
|
| 4157 | $repository->beginTransaction(); |
|
| 4158 | ||
| 4159 | try { |
|
| 4160 | $draft = $this->createContentDraftVersion1(); |
|
| 4161 | ||
| 4162 | $contentId = $draft->id; |
|
| 4163 | ||
| 4164 | // Roleback the transaction |
|
| 4165 | $repository->commit(); |
|
| 4166 | } catch (Exception $e) { |
|
| 4167 | // Cleanup hanging transaction on error |
|
| 4168 | $repository->rollback(); |
|
| 4169 | throw $e; |
|
| 4170 | } |
|
| 4171 | ||
| 4172 | // Load the new content object |
|
| 4173 | $content = $contentService->loadContent($contentId); |
|
| 4174 | /* END: Use Case */ |
|
| 4175 | ||
| 4176 | $this->assertEquals($contentId, $content->id); |
|
| 4177 | } |
|
| 4178 | ||
| 4179 | /** |
|
| 4180 | * Test for the createContentDraft() method. |
|