| @@ 3006-3039 (lines=34) @@ | ||
| 3003 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3004 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3005 | */ |
|
| 3006 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3007 | { |
|
| 3008 | $repository = $this->getRepository(); |
|
| 3009 | ||
| 3010 | /* BEGIN: Use Case */ |
|
| 3011 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3012 | ||
| 3013 | // Get create struct and set language property |
|
| 3014 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3015 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3016 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3017 | */ |
|
| 3018 | ||
| 3019 | // Start a new transaction |
|
| 3020 | $repository->beginTransaction(); |
|
| 3021 | ||
| 3022 | try { |
|
| 3023 | // Create the new content type group |
|
| 3024 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3025 | ||
| 3026 | // Rollback all changes |
|
| 3027 | $repository->commit(); |
|
| 3028 | } catch (Exception $e) { |
|
| 3029 | // Cleanup hanging transaction on error |
|
| 3030 | $repository->rollback(); |
|
| 3031 | throw $e; |
|
| 3032 | } |
|
| 3033 | ||
| 3034 | // Load created content type group |
|
| 3035 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3036 | /* END: Use Case */ |
|
| 3037 | ||
| 3038 | $this->assertEquals($groupId, $group->id); |
|
| 3039 | } |
|
| 3040 | ||
| 3041 | /** |
|
| 3042 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3393-3423 (lines=31) @@ | ||
| 3390 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3391 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3392 | */ |
|
| 3393 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3394 | { |
|
| 3395 | $repository = $this->getRepository(); |
|
| 3396 | ||
| 3397 | /* BEGIN: Use Case */ |
|
| 3398 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3399 | ||
| 3400 | // Load content type to copy |
|
| 3401 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3402 | ||
| 3403 | // Start a new transaction |
|
| 3404 | $repository->beginTransaction(); |
|
| 3405 | ||
| 3406 | try { |
|
| 3407 | // Complete copy of the content type |
|
| 3408 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3409 | ||
| 3410 | // Commit all changes |
|
| 3411 | $repository->commit(); |
|
| 3412 | } catch (Exception $e) { |
|
| 3413 | // Cleanup hanging transaction on error |
|
| 3414 | $repository->rollback(); |
|
| 3415 | throw $e; |
|
| 3416 | } |
|
| 3417 | ||
| 3418 | // Load the new content type copy. |
|
| 3419 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3420 | /* END: Use Case */ |
|
| 3421 | ||
| 3422 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3423 | } |
|
| 3424 | ||
| 3425 | /** |
|
| 3426 | * Test for the deleteContentType() method. |
|
| @@ 3681-3709 (lines=29) @@ | ||
| 3678 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 3679 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 3680 | */ |
|
| 3681 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 3682 | { |
|
| 3683 | $repository = $this->getRepository(); |
|
| 3684 | ||
| 3685 | $contentService = $repository->getContentService(); |
|
| 3686 | ||
| 3687 | /* BEGIN: Use Case */ |
|
| 3688 | // Start a transaction |
|
| 3689 | $repository->beginTransaction(); |
|
| 3690 | ||
| 3691 | try { |
|
| 3692 | $draft = $this->createContentDraftVersion1(); |
|
| 3693 | ||
| 3694 | $contentId = $draft->id; |
|
| 3695 | ||
| 3696 | // Roleback the transaction |
|
| 3697 | $repository->commit(); |
|
| 3698 | } catch (Exception $e) { |
|
| 3699 | // Cleanup hanging transaction on error |
|
| 3700 | $repository->rollback(); |
|
| 3701 | throw $e; |
|
| 3702 | } |
|
| 3703 | ||
| 3704 | // Load the new content object |
|
| 3705 | $content = $contentService->loadContent($contentId); |
|
| 3706 | /* END: Use Case */ |
|
| 3707 | ||
| 3708 | $this->assertEquals($contentId, $content->id); |
|
| 3709 | } |
|
| 3710 | ||
| 3711 | /** |
|
| 3712 | * Test for the createContentDraft() method. |
|