@@ 3552-3589 (lines=38) @@ | ||
3549 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
3550 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
3551 | */ |
|
3552 | public function testCreateContentTypeGroupInTransactionWithRollback() |
|
3553 | { |
|
3554 | $repository = $this->getRepository(); |
|
3555 | ||
3556 | /* BEGIN: Use Case */ |
|
3557 | $contentTypeService = $repository->getContentTypeService(); |
|
3558 | ||
3559 | // Get create struct and set language property |
|
3560 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
3561 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
3562 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
3563 | */ |
|
3564 | ||
3565 | // Start a new transaction |
|
3566 | $repository->beginTransaction(); |
|
3567 | ||
3568 | try { |
|
3569 | // Create the new content type group |
|
3570 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
3571 | } catch (Exception $e) { |
|
3572 | // Cleanup hanging transaction on error |
|
3573 | $repository->rollback(); |
|
3574 | throw $e; |
|
3575 | } |
|
3576 | ||
3577 | // Rollback all changes |
|
3578 | $repository->rollback(); |
|
3579 | ||
3580 | try { |
|
3581 | // This call will fail with a "NotFoundException" |
|
3582 | $contentTypeService->loadContentTypeGroup($groupId); |
|
3583 | } catch (NotFoundException $e) { |
|
3584 | return; |
|
3585 | } |
|
3586 | /* END: Use Case */ |
|
3587 | ||
3588 | $this->fail('Can still load content type group after rollback'); |
|
3589 | } |
|
3590 | ||
3591 | /** |
|
3592 | * Test for the createContentTypeGroup() method. |
|
@@ 3728-3767 (lines=40) @@ | ||
3725 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentTypeGroup |
|
3726 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifierThrowsNotFoundException |
|
3727 | */ |
|
3728 | public function testDeleteContentTypeGroupWithRollback() |
|
3729 | { |
|
3730 | $repository = $this->getRepository(); |
|
3731 | ||
3732 | /* BEGIN: Use Case */ |
|
3733 | $contentTypeService = $repository->getContentTypeService(); |
|
3734 | ||
3735 | // Get a group create struct |
|
3736 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct( |
|
3737 | 'new-group' |
|
3738 | ); |
|
3739 | ||
3740 | // Start a new transaction |
|
3741 | $repository->beginTransaction(); |
|
3742 | ||
3743 | try { |
|
3744 | // Create the new group |
|
3745 | $group = $contentTypeService->createContentTypeGroup($groupCreate); |
|
3746 | ||
3747 | // Delete the currently created group |
|
3748 | $contentTypeService->deleteContentTypeGroup($group); |
|
3749 | } catch (Exception $e) { |
|
3750 | // Cleanup hanging transaction on error |
|
3751 | $repository->rollback(); |
|
3752 | throw $e; |
|
3753 | } |
|
3754 | ||
3755 | // Rollback all changes |
|
3756 | $repository->rollback(); |
|
3757 | ||
3758 | try { |
|
3759 | // This call will fail with an "NotFoundException" |
|
3760 | $contentTypeService->loadContentTypeGroupByIdentifier('new-group'); |
|
3761 | } catch (NotFoundException $e) { |
|
3762 | // Expected error path |
|
3763 | } |
|
3764 | /* END: Use Case */ |
|
3765 | ||
3766 | $this->assertTrue(isset($e), 'Group not deleted after rollback'); |
|
3767 | } |
|
3768 | ||
3769 | /** |
|
3770 | * Test for the deleteContentTypeGroup() method. |
|
@@ 3776-3815 (lines=40) @@ | ||
3773 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testDeleteContentTypeGroup |
|
3774 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroupByIdentifierThrowsNotFoundException |
|
3775 | */ |
|
3776 | public function testDeleteContentTypeGroupWithCommit() |
|
3777 | { |
|
3778 | $repository = $this->getRepository(); |
|
3779 | ||
3780 | /* BEGIN: Use Case */ |
|
3781 | $contentTypeService = $repository->getContentTypeService(); |
|
3782 | ||
3783 | // Get a group create struct |
|
3784 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct( |
|
3785 | 'new-group' |
|
3786 | ); |
|
3787 | ||
3788 | // Start a new transaction |
|
3789 | $repository->beginTransaction(); |
|
3790 | ||
3791 | try { |
|
3792 | // Create the new group |
|
3793 | $group = $contentTypeService->createContentTypeGroup($groupCreate); |
|
3794 | ||
3795 | // Delete the currently created group |
|
3796 | $contentTypeService->deleteContentTypeGroup($group); |
|
3797 | ||
3798 | // Commit all changes |
|
3799 | $repository->commit(); |
|
3800 | } catch (Exception $e) { |
|
3801 | // Cleanup hanging transaction on error |
|
3802 | $repository->rollback(); |
|
3803 | throw $e; |
|
3804 | } |
|
3805 | ||
3806 | try { |
|
3807 | // This call will fail with an "NotFoundException" |
|
3808 | $contentTypeService->loadContentTypeGroupByIdentifier('new-group'); |
|
3809 | } catch (NotFoundException $e) { |
|
3810 | // Expected error path |
|
3811 | } |
|
3812 | /* END: Use Case */ |
|
3813 | ||
3814 | $this->assertTrue(isset($e), 'Group not deleted after commit.'); |
|
3815 | } |
|
3816 | ||
3817 | /** |
|
3818 | * Test for the createContentType() method. |
|
@@ 3941-3975 (lines=35) @@ | ||
3938 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
3939 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
3940 | */ |
|
3941 | public function testCopyContentTypeInTransactionWithRollback() |
|
3942 | { |
|
3943 | $repository = $this->getRepository(); |
|
3944 | ||
3945 | /* BEGIN: Use Case */ |
|
3946 | $contentTypeService = $repository->getContentTypeService(); |
|
3947 | ||
3948 | // Load content type to copy |
|
3949 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
3950 | ||
3951 | // Start a new transaction |
|
3952 | $repository->beginTransaction(); |
|
3953 | ||
3954 | try { |
|
3955 | // Complete copy of the content type |
|
3956 | $copiedType = $contentTypeService->copyContentType($contentType); |
|
3957 | } catch (Exception $e) { |
|
3958 | // Cleanup hanging transaction on error |
|
3959 | $repository->rollback(); |
|
3960 | throw $e; |
|
3961 | } |
|
3962 | ||
3963 | // Rollback all changes |
|
3964 | $repository->rollback(); |
|
3965 | ||
3966 | try { |
|
3967 | // This call will fail with a "NotFoundException" |
|
3968 | $contentTypeService->loadContentType($copiedType->id); |
|
3969 | } catch (NotFoundException $e) { |
|
3970 | // Expected execution path |
|
3971 | } |
|
3972 | /* END: Use Case */ |
|
3973 | ||
3974 | $this->assertTrue(isset($e), 'Can still load copied content type after rollback.'); |
|
3975 | } |
|
3976 | ||
3977 | /** |
|
3978 | * Test for the copyContentType() method. |
|
@@ 4063-4097 (lines=35) @@ | ||
4060 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCopyContentType |
|
4061 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifierThrowsNotFoundException |
|
4062 | */ |
|
4063 | public function testDeleteContentTypeInTransactionWithCommit() |
|
4064 | { |
|
4065 | $repository = $this->getRepository(); |
|
4066 | ||
4067 | /* BEGIN: Use Case */ |
|
4068 | $contentTypeService = $repository->getContentTypeService(); |
|
4069 | ||
4070 | // Load content type to copy |
|
4071 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
4072 | ||
4073 | // Start a new transaction |
|
4074 | $repository->beginTransaction(); |
|
4075 | ||
4076 | try { |
|
4077 | // Delete the "comment" content type. |
|
4078 | $contentTypeService->deleteContentType($contentType); |
|
4079 | ||
4080 | // Commit all changes |
|
4081 | $repository->commit(); |
|
4082 | } catch (Exception $e) { |
|
4083 | // Cleanup hanging transaction on error |
|
4084 | $repository->rollback(); |
|
4085 | throw $e; |
|
4086 | } |
|
4087 | ||
4088 | try { |
|
4089 | // This call will fail with a "NotFoundException" |
|
4090 | $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
4091 | } catch (NotFoundException $e) { |
|
4092 | // Expected execution path |
|
4093 | } |
|
4094 | /* END: Use Case */ |
|
4095 | ||
4096 | $this->assertTrue(isset($e), 'Can still load content type after rollback.'); |
|
4097 | } |
|
4098 | ||
4099 | /** |
|
4100 | * Test for the assignContentTypeGroup() method. |
@@ 716-746 (lines=31) @@ | ||
713 | * @covers \eZ\Publish\API\Repository\LanguageService::updateLanguageName |
|
714 | * @depends eZ\Publish\API\Repository\Tests\LanguageServiceTest::testUpdateLanguageName |
|
715 | */ |
|
716 | public function testUpdateLanguageNameInTransactionWithCommit() |
|
717 | { |
|
718 | $repository = $this->getRepository(); |
|
719 | ||
720 | /* BEGIN: Use Case */ |
|
721 | $languageService = $repository->getContentLanguageService(); |
|
722 | ||
723 | // Start a new transaction |
|
724 | $repository->beginTransaction(); |
|
725 | ||
726 | try { |
|
727 | // Load an existing language |
|
728 | $language = $languageService->loadLanguage('eng-US'); |
|
729 | ||
730 | // Update the language name |
|
731 | $languageService->updateLanguageName($language, 'My English'); |
|
732 | ||
733 | // Commit all changes |
|
734 | $repository->commit(); |
|
735 | } catch (Exception $e) { |
|
736 | // Cleanup hanging transaction on error |
|
737 | $repository->rollback(); |
|
738 | throw $e; |
|
739 | } |
|
740 | ||
741 | // Load updated version, name will be "My English" |
|
742 | $updatedLanguage = $languageService->loadLanguage('eng-US'); |
|
743 | /* END: Use Case */ |
|
744 | ||
745 | $this->assertEquals('My English', $updatedLanguage->name); |
|
746 | } |
|
747 | } |
|
748 |