| @@ 3383-3416 (lines=34) @@ | ||
| 3380 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3381 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3382 | */ |
|
| 3383 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3384 | { |
|
| 3385 | $repository = $this->getRepository(); |
|
| 3386 | ||
| 3387 | /* BEGIN: Use Case */ |
|
| 3388 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3389 | ||
| 3390 | // Get create struct and set language property |
|
| 3391 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3392 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3393 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3394 | */ |
|
| 3395 | ||
| 3396 | // Start a new transaction |
|
| 3397 | $repository->beginTransaction(); |
|
| 3398 | ||
| 3399 | try { |
|
| 3400 | // Create the new content type group |
|
| 3401 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3402 | ||
| 3403 | // Rollback all changes |
|
| 3404 | $repository->commit(); |
|
| 3405 | } catch (Exception $e) { |
|
| 3406 | // Cleanup hanging transaction on error |
|
| 3407 | $repository->rollback(); |
|
| 3408 | throw $e; |
|
| 3409 | } |
|
| 3410 | ||
| 3411 | // Load created content type group |
|
| 3412 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3413 | /* END: Use Case */ |
|
| 3414 | ||
| 3415 | $this->assertEquals($groupId, $group->id); |
|
| 3416 | } |
|
| 3417 | ||
| 3418 | /** |
|
| 3419 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3770-3800 (lines=31) @@ | ||
| 3767 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3768 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3769 | */ |
|
| 3770 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3771 | { |
|
| 3772 | $repository = $this->getRepository(); |
|
| 3773 | ||
| 3774 | /* BEGIN: Use Case */ |
|
| 3775 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3776 | ||
| 3777 | // Load content type to copy |
|
| 3778 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3779 | ||
| 3780 | // Start a new transaction |
|
| 3781 | $repository->beginTransaction(); |
|
| 3782 | ||
| 3783 | try { |
|
| 3784 | // Complete copy of the content type |
|
| 3785 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3786 | ||
| 3787 | // Commit all changes |
|
| 3788 | $repository->commit(); |
|
| 3789 | } catch (Exception $e) { |
|
| 3790 | // Cleanup hanging transaction on error |
|
| 3791 | $repository->rollback(); |
|
| 3792 | throw $e; |
|
| 3793 | } |
|
| 3794 | ||
| 3795 | // Load the new content type copy. |
|
| 3796 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3797 | /* END: Use Case */ |
|
| 3798 | ||
| 3799 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3800 | } |
|
| 3801 | ||
| 3802 | /** |
|
| 3803 | * Test for the deleteContentType() method. |
|
| @@ 4276-4304 (lines=29) @@ | ||
| 4273 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4274 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4275 | */ |
|
| 4276 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4277 | { |
|
| 4278 | $repository = $this->getRepository(); |
|
| 4279 | ||
| 4280 | $contentService = $repository->getContentService(); |
|
| 4281 | ||
| 4282 | /* BEGIN: Use Case */ |
|
| 4283 | // Start a transaction |
|
| 4284 | $repository->beginTransaction(); |
|
| 4285 | ||
| 4286 | try { |
|
| 4287 | $draft = $this->createContentDraftVersion1(); |
|
| 4288 | ||
| 4289 | $contentId = $draft->id; |
|
| 4290 | ||
| 4291 | // Roleback the transaction |
|
| 4292 | $repository->commit(); |
|
| 4293 | } catch (Exception $e) { |
|
| 4294 | // Cleanup hanging transaction on error |
|
| 4295 | $repository->rollback(); |
|
| 4296 | throw $e; |
|
| 4297 | } |
|
| 4298 | ||
| 4299 | // Load the new content object |
|
| 4300 | $content = $contentService->loadContent($contentId); |
|
| 4301 | /* END: Use Case */ |
|
| 4302 | ||
| 4303 | $this->assertEquals($contentId, $content->id); |
|
| 4304 | } |
|
| 4305 | ||
| 4306 | /** |
|
| 4307 | * Test for the createContentDraft() method. |
|