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