| @@ 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. |
|
| @@ 4365-4393 (lines=29) @@ | ||
| 4362 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4363 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4364 | */ |
|
| 4365 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4366 | { |
|
| 4367 | $repository = $this->getRepository(); |
|
| 4368 | ||
| 4369 | $contentService = $repository->getContentService(); |
|
| 4370 | ||
| 4371 | /* BEGIN: Use Case */ |
|
| 4372 | // Start a transaction |
|
| 4373 | $repository->beginTransaction(); |
|
| 4374 | ||
| 4375 | try { |
|
| 4376 | $draft = $this->createContentDraftVersion1(); |
|
| 4377 | ||
| 4378 | $contentId = $draft->id; |
|
| 4379 | ||
| 4380 | // Roleback the transaction |
|
| 4381 | $repository->commit(); |
|
| 4382 | } catch (Exception $e) { |
|
| 4383 | // Cleanup hanging transaction on error |
|
| 4384 | $repository->rollback(); |
|
| 4385 | throw $e; |
|
| 4386 | } |
|
| 4387 | ||
| 4388 | // Load the new content object |
|
| 4389 | $content = $contentService->loadContent($contentId); |
|
| 4390 | /* END: Use Case */ |
|
| 4391 | ||
| 4392 | $this->assertEquals($contentId, $content->id); |
|
| 4393 | } |
|
| 4394 | ||
| 4395 | /** |
|
| 4396 | * Test for the createContentDraft() method. |
|