@@ 3598-3631 (lines=34) @@ | ||
3595 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
3596 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
3597 | */ |
|
3598 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
3599 | { |
|
3600 | $repository = $this->getRepository(); |
|
3601 | ||
3602 | /* BEGIN: Use Case */ |
|
3603 | $contentTypeService = $repository->getContentTypeService(); |
|
3604 | ||
3605 | // Get create struct and set language property |
|
3606 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
3607 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
3608 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
3609 | */ |
|
3610 | ||
3611 | // Start a new transaction |
|
3612 | $repository->beginTransaction(); |
|
3613 | ||
3614 | try { |
|
3615 | // Create the new content type group |
|
3616 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
3617 | ||
3618 | // Rollback all changes |
|
3619 | $repository->commit(); |
|
3620 | } catch (Exception $e) { |
|
3621 | // Cleanup hanging transaction on error |
|
3622 | $repository->rollback(); |
|
3623 | throw $e; |
|
3624 | } |
|
3625 | ||
3626 | // Load created content type group |
|
3627 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
3628 | /* END: Use Case */ |
|
3629 | ||
3630 | $this->assertEquals($groupId, $group->id); |
|
3631 | } |
|
3632 | ||
3633 | /** |
|
3634 | * Test for the updateContentTypeGroup() method. |
|
@@ 3985-4015 (lines=31) @@ | ||
3982 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
3983 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
3984 | */ |
|
3985 | public function testCopyContentTypeInTransactionWithCommit() |
|
3986 | { |
|
3987 | $repository = $this->getRepository(); |
|
3988 | ||
3989 | /* BEGIN: Use Case */ |
|
3990 | $contentTypeService = $repository->getContentTypeService(); |
|
3991 | ||
3992 | // Load content type to copy |
|
3993 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
3994 | ||
3995 | // Start a new transaction |
|
3996 | $repository->beginTransaction(); |
|
3997 | ||
3998 | try { |
|
3999 | // Complete copy of the content type |
|
4000 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
4001 | ||
4002 | // Commit all changes |
|
4003 | $repository->commit(); |
|
4004 | } catch (Exception $e) { |
|
4005 | // Cleanup hanging transaction on error |
|
4006 | $repository->rollback(); |
|
4007 | throw $e; |
|
4008 | } |
|
4009 | ||
4010 | // Load the new content type copy. |
|
4011 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
4012 | /* END: Use Case */ |
|
4013 | ||
4014 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
4015 | } |
|
4016 | ||
4017 | /** |
|
4018 | * Test for the deleteContentType() method. |