| @@ 3519-3552 (lines=34) @@ | ||
| 3516 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeGroup |
|
| 3517 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testCreateContentTypeGroup |
|
| 3518 | */ |
|
| 3519 | public function testCreateContentTypeGroupInTransactionWithCommit() |
|
| 3520 | { |
|
| 3521 | $repository = $this->getRepository(); |
|
| 3522 | ||
| 3523 | /* BEGIN: Use Case */ |
|
| 3524 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3525 | ||
| 3526 | // Get create struct and set language property |
|
| 3527 | $groupCreate = $contentTypeService->newContentTypeGroupCreateStruct('new-group'); |
|
| 3528 | /* @todo uncomment when support for multilingual names and descriptions is added |
|
| 3529 | $groupCreate->mainLanguageCode = 'eng-GB'; |
|
| 3530 | */ |
|
| 3531 | ||
| 3532 | // Start a new transaction |
|
| 3533 | $repository->beginTransaction(); |
|
| 3534 | ||
| 3535 | try { |
|
| 3536 | // Create the new content type group |
|
| 3537 | $groupId = $contentTypeService->createContentTypeGroup($groupCreate)->id; |
|
| 3538 | ||
| 3539 | // Rollback all changes |
|
| 3540 | $repository->commit(); |
|
| 3541 | } catch (Exception $e) { |
|
| 3542 | // Cleanup hanging transaction on error |
|
| 3543 | $repository->rollback(); |
|
| 3544 | throw $e; |
|
| 3545 | } |
|
| 3546 | ||
| 3547 | // Load created content type group |
|
| 3548 | $group = $contentTypeService->loadContentTypeGroup($groupId); |
|
| 3549 | /* END: Use Case */ |
|
| 3550 | ||
| 3551 | $this->assertEquals($groupId, $group->id); |
|
| 3552 | } |
|
| 3553 | ||
| 3554 | /** |
|
| 3555 | * Test for the updateContentTypeGroup() method. |
|
| @@ 3906-3936 (lines=31) @@ | ||
| 3903 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeByIdentifier |
|
| 3904 | * @depends eZ\Publish\API\Repository\Tests\ContentTypeServiceTest::testLoadContentTypeThrowsNotFoundException |
|
| 3905 | */ |
|
| 3906 | public function testCopyContentTypeInTransactionWithCommit() |
|
| 3907 | { |
|
| 3908 | $repository = $this->getRepository(); |
|
| 3909 | ||
| 3910 | /* BEGIN: Use Case */ |
|
| 3911 | $contentTypeService = $repository->getContentTypeService(); |
|
| 3912 | ||
| 3913 | // Load content type to copy |
|
| 3914 | $contentType = $contentTypeService->loadContentTypeByIdentifier('comment'); |
|
| 3915 | ||
| 3916 | // Start a new transaction |
|
| 3917 | $repository->beginTransaction(); |
|
| 3918 | ||
| 3919 | try { |
|
| 3920 | // Complete copy of the content type |
|
| 3921 | $contentTypeId = $contentTypeService->copyContentType($contentType)->id; |
|
| 3922 | ||
| 3923 | // Commit all changes |
|
| 3924 | $repository->commit(); |
|
| 3925 | } catch (Exception $e) { |
|
| 3926 | // Cleanup hanging transaction on error |
|
| 3927 | $repository->rollback(); |
|
| 3928 | throw $e; |
|
| 3929 | } |
|
| 3930 | ||
| 3931 | // Load the new content type copy. |
|
| 3932 | $copiedContentType = $contentTypeService->loadContentType($contentTypeId); |
|
| 3933 | /* END: Use Case */ |
|
| 3934 | ||
| 3935 | $this->assertEquals($contentTypeId, $copiedContentType->id); |
|
| 3936 | } |
|
| 3937 | ||
| 3938 | /** |
|
| 3939 | * Test for the deleteContentType() method. |
|
| @@ 4372-4400 (lines=29) @@ | ||
| 4369 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCreateContentWithLocationCreateParameterDoesNotCreateLocationImmediately |
|
| 4370 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentThrowsNotFoundException |
|
| 4371 | */ |
|
| 4372 | public function testCreateContentWithLocationCreateParameterInTransactionWithCommit() |
|
| 4373 | { |
|
| 4374 | $repository = $this->getRepository(); |
|
| 4375 | ||
| 4376 | $contentService = $repository->getContentService(); |
|
| 4377 | ||
| 4378 | /* BEGIN: Use Case */ |
|
| 4379 | // Start a transaction |
|
| 4380 | $repository->beginTransaction(); |
|
| 4381 | ||
| 4382 | try { |
|
| 4383 | $draft = $this->createContentDraftVersion1(); |
|
| 4384 | ||
| 4385 | $contentId = $draft->id; |
|
| 4386 | ||
| 4387 | // Roleback the transaction |
|
| 4388 | $repository->commit(); |
|
| 4389 | } catch (Exception $e) { |
|
| 4390 | // Cleanup hanging transaction on error |
|
| 4391 | $repository->rollback(); |
|
| 4392 | throw $e; |
|
| 4393 | } |
|
| 4394 | ||
| 4395 | // Load the new content object |
|
| 4396 | $content = $contentService->loadContent($contentId); |
|
| 4397 | /* END: Use Case */ |
|
| 4398 | ||
| 4399 | $this->assertEquals($contentId, $content->id); |
|
| 4400 | } |
|
| 4401 | ||
| 4402 | /** |
|
| 4403 | * Test for the createContentDraft() method. |
|