|
@@ 4825-4860 (lines=36) @@
|
| 4822 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4823 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4824 |
|
*/ |
| 4825 |
|
public function testDeleteVersionInTransactionWithRollback() |
| 4826 |
|
{ |
| 4827 |
|
$repository = $this->getRepository(); |
| 4828 |
|
|
| 4829 |
|
$contentId = $this->generateId('object', 12); |
| 4830 |
|
/* BEGIN: Use Case */ |
| 4831 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4832 |
|
|
| 4833 |
|
// Get the content service |
| 4834 |
|
$contentService = $repository->getContentService(); |
| 4835 |
|
|
| 4836 |
|
// Start a new transaction |
| 4837 |
|
$repository->beginTransaction(); |
| 4838 |
|
|
| 4839 |
|
try { |
| 4840 |
|
// Create a new draft |
| 4841 |
|
$draft = $contentService->createContentDraft( |
| 4842 |
|
$contentService->loadContentInfo($contentId) |
| 4843 |
|
); |
| 4844 |
|
|
| 4845 |
|
$contentService->deleteVersion($draft->getVersionInfo()); |
| 4846 |
|
} catch (Exception $e) { |
| 4847 |
|
// Cleanup hanging transaction on error |
| 4848 |
|
$repository->rollback(); |
| 4849 |
|
throw $e; |
| 4850 |
|
} |
| 4851 |
|
|
| 4852 |
|
// Rollback all changes. |
| 4853 |
|
$repository->rollback(); |
| 4854 |
|
|
| 4855 |
|
// This array will be empty |
| 4856 |
|
$drafts = $contentService->loadContentDrafts(); |
| 4857 |
|
/* END: Use Case */ |
| 4858 |
|
|
| 4859 |
|
$this->assertSame([], $drafts); |
| 4860 |
|
} |
| 4861 |
|
|
| 4862 |
|
/** |
| 4863 |
|
* Test for the deleteVersion() method. |
|
@@ 4870-4905 (lines=36) @@
|
| 4867 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4868 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4869 |
|
*/ |
| 4870 |
|
public function testDeleteVersionInTransactionWithCommit() |
| 4871 |
|
{ |
| 4872 |
|
$repository = $this->getRepository(); |
| 4873 |
|
|
| 4874 |
|
$contentId = $this->generateId('object', 12); |
| 4875 |
|
/* BEGIN: Use Case */ |
| 4876 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4877 |
|
|
| 4878 |
|
// Get the content service |
| 4879 |
|
$contentService = $repository->getContentService(); |
| 4880 |
|
|
| 4881 |
|
// Start a new transaction |
| 4882 |
|
$repository->beginTransaction(); |
| 4883 |
|
|
| 4884 |
|
try { |
| 4885 |
|
// Create a new draft |
| 4886 |
|
$draft = $contentService->createContentDraft( |
| 4887 |
|
$contentService->loadContentInfo($contentId) |
| 4888 |
|
); |
| 4889 |
|
|
| 4890 |
|
$contentService->deleteVersion($draft->getVersionInfo()); |
| 4891 |
|
|
| 4892 |
|
// Commit all changes. |
| 4893 |
|
$repository->commit(); |
| 4894 |
|
} catch (Exception $e) { |
| 4895 |
|
// Cleanup hanging transaction on error |
| 4896 |
|
$repository->rollback(); |
| 4897 |
|
throw $e; |
| 4898 |
|
} |
| 4899 |
|
|
| 4900 |
|
// This array will contain no element |
| 4901 |
|
$drafts = $contentService->loadContentDrafts(); |
| 4902 |
|
/* END: Use Case */ |
| 4903 |
|
|
| 4904 |
|
$this->assertSame([], $drafts); |
| 4905 |
|
} |
| 4906 |
|
|
| 4907 |
|
/** |
| 4908 |
|
* Test for the deleteContent() method. |
|
@@ 4914-4949 (lines=36) @@
|
| 4911 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent |
| 4912 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4913 |
|
*/ |
| 4914 |
|
public function testDeleteContentInTransactionWithRollback() |
| 4915 |
|
{ |
| 4916 |
|
$repository = $this->getRepository(); |
| 4917 |
|
|
| 4918 |
|
$contentId = $this->generateId('object', 11); |
| 4919 |
|
/* BEGIN: Use Case */ |
| 4920 |
|
// $contentId is the ID of the "Members" user group in an eZ Publish |
| 4921 |
|
// demo installation |
| 4922 |
|
|
| 4923 |
|
// Get content service |
| 4924 |
|
$contentService = $repository->getContentService(); |
| 4925 |
|
|
| 4926 |
|
// Load a ContentInfo instance |
| 4927 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 4928 |
|
|
| 4929 |
|
// Start a new transaction |
| 4930 |
|
$repository->beginTransaction(); |
| 4931 |
|
|
| 4932 |
|
try { |
| 4933 |
|
// Delete content object |
| 4934 |
|
$contentService->deleteContent($contentInfo); |
| 4935 |
|
} catch (Exception $e) { |
| 4936 |
|
// Cleanup hanging transaction on error |
| 4937 |
|
$repository->rollback(); |
| 4938 |
|
throw $e; |
| 4939 |
|
} |
| 4940 |
|
|
| 4941 |
|
// Rollback all changes |
| 4942 |
|
$repository->rollback(); |
| 4943 |
|
|
| 4944 |
|
// This call will return the original content object |
| 4945 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 4946 |
|
/* END: Use Case */ |
| 4947 |
|
|
| 4948 |
|
$this->assertEquals($contentId, $contentInfo->id); |
| 4949 |
|
} |
| 4950 |
|
|
| 4951 |
|
/** |
| 4952 |
|
* Test for the deleteContent() method. |