| @@ 3562-3595 (lines=34) @@ | ||
| 3559 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3560 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3561 | */ |
|
| 3562 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3563 | { |
|
| 3564 | $repository = $this->getRepository(); |
|
| 3565 | ||
| 3566 | /* BEGIN: Use Case */ |
|
| 3567 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3568 | ||
| 3569 | // Get create struct and set language property |
|
| 3570 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3571 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3572 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3573 | */ |
|
| 3574 | ||
| 3575 | // Start a new transaction |
|
| 3576 | $repository->beginTransaction(); |
|
| 3577 | ||
| 3578 | try { |
|
| 3579 | // Create the new content type group |
|
| 3580 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3581 | ||
| 3582 | // Rollback all changes |
|
| 3583 | $repository->commit(); |
|
| 3584 | } catch (Exception $e) { |
|
| 3585 | // Cleanup hanging transaction on error |
|
| 3586 | $repository->rollback(); |
|
| 3587 | throw $e; |
|
| 3588 | } |
|
| 3589 | ||
| 3590 | // Load created content type group |
|
| 3591 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3592 | /* END: Use Case */ |
|
| 3593 | ||
| 3594 | $this->assertEquals($groupId, $group->id); |
|
| 3595 | } |
|
| 3596 | ||
| 3597 | /** |
|
| 3598 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3949-3979 (lines=31) @@ | ||
| 3946 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3947 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3948 | */ |
|
| 3949 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3950 | { |
|
| 3951 | $repository = $this->getRepository(); |
|
| 3952 | ||
| 3953 | /* BEGIN: Use Case */ |
|
| 3954 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3955 | ||
| 3956 | // Load content type to copy |
|
| 3957 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3958 | ||
| 3959 | // Start a new transaction |
|
| 3960 | $repository->beginTransaction(); |
|
| 3961 | ||
| 3962 | try { |
|
| 3963 | // Complete copy of the content type |
|
| 3964 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3965 | ||
| 3966 | // Commit all changes |
|
| 3967 | $repository->commit(); |
|
| 3968 | } catch (Exception $e) { |
|
| 3969 | // Cleanup hanging transaction on error |
|
| 3970 | $repository->rollback(); |
|
| 3971 | throw $e; |
|
| 3972 | } |
|
| 3973 | ||
| 3974 | // Load the new content type copy. |
|
| 3975 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3976 | /* END: Use Case */ |
|
| 3977 | ||
| 3978 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3979 | } |
|
| 3980 | ||
| 3981 | /** |
|
| 3982 | * Test for the deleteContentType() method. |
|
| @@ 4371-4399 (lines=29) @@ | ||
| 4368 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4369 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4370 | */ |
|
| 4371 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4372 | { |
|
| 4373 | $repository = $this->getRepository(); |
|
| 4374 | ||
| 4375 | $contentService = $repository->getContentService(); |
|
| 4376 | ||
| 4377 | /* BEGIN: Use Case */ |
|
| 4378 | // Start a transaction |
|
| 4379 | $repository->beginTransaction(); |
|
| 4380 | ||
| 4381 | try { |
|
| 4382 | $draft = $this->createContentDraftVersion1(); |
|
| 4383 | ||
| 4384 | $contentId = $draft->id; |
|
| 4385 | ||
| 4386 | // Roleback the transaction |
|
| 4387 | $repository->commit(); |
|
| 4388 | } catch (Exception $e) { |
|
| 4389 | // Cleanup hanging transaction on error |
|
| 4390 | $repository->rollback(); |
|
| 4391 | throw $e; |
|
| 4392 | } |
|
| 4393 | ||
| 4394 | // Load the new content object |
|
| 4395 | $content = $contentService->loadContent($contentId); |
|
| 4396 | /* END: Use Case */ |
|
| 4397 | ||
| 4398 | $this->assertEquals($contentId, $content->id); |
|
| 4399 | } |
|
| 4400 | ||
| 4401 | /** |
|
| 4402 | * Test for the createContentDraft() method. |
|