| @@ 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. |
|
| @@ 4119-4147 (lines=29) @@ | ||
| 4116 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4117 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4118 | */ |
|
| 4119 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4120 | { |
|
| 4121 | $repository = $this->getRepository(); |
|
| 4122 | ||
| 4123 | $contentService = $repository->getContentService(); |
|
| 4124 | ||
| 4125 | /* BEGIN: Use Case */ |
|
| 4126 | // Start a transaction |
|
| 4127 | $repository->beginTransaction(); |
|
| 4128 | ||
| 4129 | try { |
|
| 4130 | $draft = $this->createContentDraftVersion1(); |
|
| 4131 | ||
| 4132 | $contentId = $draft->id; |
|
| 4133 | ||
| 4134 | // Roleback the transaction |
|
| 4135 | $repository->commit(); |
|
| 4136 | } catch (Exception $e) { |
|
| 4137 | // Cleanup hanging transaction on error |
|
| 4138 | $repository->rollback(); |
|
| 4139 | throw $e; |
|
| 4140 | } |
|
| 4141 | ||
| 4142 | // Load the new content object |
|
| 4143 | $content = $contentService->loadContent($contentId); |
|
| 4144 | /* END: Use Case */ |
|
| 4145 | ||
| 4146 | $this->assertEquals($contentId, $content->id); |
|
| 4147 | } |
|
| 4148 | ||
| 4149 | /** |
|
| 4150 | * Test for the createContentDraft() method. |
|