| @@ 3311-3344 (lines=34) @@ | ||
| 3308 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3309 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3310 | */ |
|
| 3311 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3312 | { |
|
| 3313 | $repository = $this->getRepository(); |
|
| 3314 | ||
| 3315 | /* BEGIN: Use Case */ |
|
| 3316 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3317 | ||
| 3318 | // Get create struct and set language property |
|
| 3319 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3320 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3321 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3322 | */ |
|
| 3323 | ||
| 3324 | // Start a new transaction |
|
| 3325 | $repository->beginTransaction(); |
|
| 3326 | ||
| 3327 | try { |
|
| 3328 | // Create the new content type group |
|
| 3329 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3330 | ||
| 3331 | // Rollback all changes |
|
| 3332 | $repository->commit(); |
|
| 3333 | } catch (Exception $e) { |
|
| 3334 | // Cleanup hanging transaction on error |
|
| 3335 | $repository->rollback(); |
|
| 3336 | throw $e; |
|
| 3337 | } |
|
| 3338 | ||
| 3339 | // Load created content type group |
|
| 3340 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3341 | /* END: Use Case */ |
|
| 3342 | ||
| 3343 | $this->assertEquals($groupId, $group->id); |
|
| 3344 | } |
|
| 3345 | ||
| 3346 | /** |
|
| 3347 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3698-3728 (lines=31) @@ | ||
| 3695 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3696 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3697 | */ |
|
| 3698 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3699 | { |
|
| 3700 | $repository = $this->getRepository(); |
|
| 3701 | ||
| 3702 | /* BEGIN: Use Case */ |
|
| 3703 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3704 | ||
| 3705 | // Load content type to copy |
|
| 3706 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3707 | ||
| 3708 | // Start a new transaction |
|
| 3709 | $repository->beginTransaction(); |
|
| 3710 | ||
| 3711 | try { |
|
| 3712 | // Complete copy of the content type |
|
| 3713 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3714 | ||
| 3715 | // Commit all changes |
|
| 3716 | $repository->commit(); |
|
| 3717 | } catch (Exception $e) { |
|
| 3718 | // Cleanup hanging transaction on error |
|
| 3719 | $repository->rollback(); |
|
| 3720 | throw $e; |
|
| 3721 | } |
|
| 3722 | ||
| 3723 | // Load the new content type copy. |
|
| 3724 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3725 | /* END: Use Case */ |
|
| 3726 | ||
| 3727 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3728 | } |
|
| 3729 | ||
| 3730 | /** |
|
| 3731 | * Test for the deleteContentType() method. |
|
| @@ 4078-4106 (lines=29) @@ | ||
| 4075 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4076 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4077 | */ |
|
| 4078 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4079 | { |
|
| 4080 | $repository = $this->getRepository(); |
|
| 4081 | ||
| 4082 | $contentService = $repository->getContentService(); |
|
| 4083 | ||
| 4084 | /* BEGIN: Use Case */ |
|
| 4085 | // Start a transaction |
|
| 4086 | $repository->beginTransaction(); |
|
| 4087 | ||
| 4088 | try { |
|
| 4089 | $draft = $this->createContentDraftVersion1(); |
|
| 4090 | ||
| 4091 | $contentId = $draft->id; |
|
| 4092 | ||
| 4093 | // Roleback the transaction |
|
| 4094 | $repository->commit(); |
|
| 4095 | } catch (Exception $e) { |
|
| 4096 | // Cleanup hanging transaction on error |
|
| 4097 | $repository->rollback(); |
|
| 4098 | throw $e; |
|
| 4099 | } |
|
| 4100 | ||
| 4101 | // Load the new content object |
|
| 4102 | $content = $contentService->loadContent($contentId); |
|
| 4103 | /* END: Use Case */ |
|
| 4104 | ||
| 4105 | $this->assertEquals($contentId, $content->id); |
|
| 4106 | } |
|
| 4107 | ||
| 4108 | /** |
|
| 4109 | * Test for the createContentDraft() method. |
|