| @@ 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. |
|
| @@ 3391-3424 (lines=34) @@ | ||
| 3388 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3389 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3390 | */ |
|
| 3391 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3392 | { |
|
| 3393 | $repository = $this->getRepository(); |
|
| 3394 | ||
| 3395 | /* BEGIN: Use Case */ |
|
| 3396 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3397 | ||
| 3398 | // Get create struct and set language property |
|
| 3399 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3400 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3401 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3402 | */ |
|
| 3403 | ||
| 3404 | // Start a new transaction |
|
| 3405 | $repository->beginTransaction(); |
|
| 3406 | ||
| 3407 | try { |
|
| 3408 | // Create the new content type group |
|
| 3409 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3410 | ||
| 3411 | // Rollback all changes |
|
| 3412 | $repository->commit(); |
|
| 3413 | } catch (Exception $e) { |
|
| 3414 | // Cleanup hanging transaction on error |
|
| 3415 | $repository->rollback(); |
|
| 3416 | throw $e; |
|
| 3417 | } |
|
| 3418 | ||
| 3419 | // Load created content type group |
|
| 3420 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3421 | /* END: Use Case */ |
|
| 3422 | ||
| 3423 | $this->assertEquals($groupId, $group->id); |
|
| 3424 | } |
|
| 3425 | ||
| 3426 | /** |
|
| 3427 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3778-3808 (lines=31) @@ | ||
| 3775 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3776 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3777 | */ |
|
| 3778 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3779 | { |
|
| 3780 | $repository = $this->getRepository(); |
|
| 3781 | ||
| 3782 | /* BEGIN: Use Case */ |
|
| 3783 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3784 | ||
| 3785 | // Load content type to copy |
|
| 3786 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3787 | ||
| 3788 | // Start a new transaction |
|
| 3789 | $repository->beginTransaction(); |
|
| 3790 | ||
| 3791 | try { |
|
| 3792 | // Complete copy of the content type |
|
| 3793 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3794 | ||
| 3795 | // Commit all changes |
|
| 3796 | $repository->commit(); |
|
| 3797 | } catch (Exception $e) { |
|
| 3798 | // Cleanup hanging transaction on error |
|
| 3799 | $repository->rollback(); |
|
| 3800 | throw $e; |
|
| 3801 | } |
|
| 3802 | ||
| 3803 | // Load the new content type copy. |
|
| 3804 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3805 | /* END: Use Case */ |
|
| 3806 | ||
| 3807 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3808 | } |
|
| 3809 | ||
| 3810 | /** |
|
| 3811 | * Test for the deleteContentType() method. |
|