|
@@ 4865-4900 (lines=36) @@
|
| 4862 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4863 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4864 |
|
*/ |
| 4865 |
|
public function testDeleteVersionInTransactionWithRollback() |
| 4866 |
|
{ |
| 4867 |
|
$repository = $this->getRepository(); |
| 4868 |
|
|
| 4869 |
|
$contentId = $this->generateId('object', 12); |
| 4870 |
|
/* BEGIN: Use Case */ |
| 4871 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4872 |
|
|
| 4873 |
|
// Get the content service |
| 4874 |
|
$contentService = $repository->getContentService(); |
| 4875 |
|
|
| 4876 |
|
// Start a new transaction |
| 4877 |
|
$repository->beginTransaction(); |
| 4878 |
|
|
| 4879 |
|
try { |
| 4880 |
|
// Create a new draft |
| 4881 |
|
$draft = $contentService->createContentDraft( |
| 4882 |
|
$contentService->loadContentInfo($contentId) |
| 4883 |
|
); |
| 4884 |
|
|
| 4885 |
|
$contentService->deleteVersion($draft->getVersionInfo()); |
| 4886 |
|
} catch (Exception $e) { |
| 4887 |
|
// Cleanup hanging transaction on error |
| 4888 |
|
$repository->rollback(); |
| 4889 |
|
throw $e; |
| 4890 |
|
} |
| 4891 |
|
|
| 4892 |
|
// Rollback all changes. |
| 4893 |
|
$repository->rollback(); |
| 4894 |
|
|
| 4895 |
|
// This array will be empty |
| 4896 |
|
$drafts = $contentService->loadContentDrafts(); |
| 4897 |
|
/* END: Use Case */ |
| 4898 |
|
|
| 4899 |
|
$this->assertSame([], $drafts); |
| 4900 |
|
} |
| 4901 |
|
|
| 4902 |
|
/** |
| 4903 |
|
* Test for the deleteVersion() method. |
|
@@ 4910-4945 (lines=36) @@
|
| 4907 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4908 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4909 |
|
*/ |
| 4910 |
|
public function testDeleteVersionInTransactionWithCommit() |
| 4911 |
|
{ |
| 4912 |
|
$repository = $this->getRepository(); |
| 4913 |
|
|
| 4914 |
|
$contentId = $this->generateId('object', 12); |
| 4915 |
|
/* BEGIN: Use Case */ |
| 4916 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4917 |
|
|
| 4918 |
|
// Get the content service |
| 4919 |
|
$contentService = $repository->getContentService(); |
| 4920 |
|
|
| 4921 |
|
// Start a new transaction |
| 4922 |
|
$repository->beginTransaction(); |
| 4923 |
|
|
| 4924 |
|
try { |
| 4925 |
|
// Create a new draft |
| 4926 |
|
$draft = $contentService->createContentDraft( |
| 4927 |
|
$contentService->loadContentInfo($contentId) |
| 4928 |
|
); |
| 4929 |
|
|
| 4930 |
|
$contentService->deleteVersion($draft->getVersionInfo()); |
| 4931 |
|
|
| 4932 |
|
// Commit all changes. |
| 4933 |
|
$repository->commit(); |
| 4934 |
|
} catch (Exception $e) { |
| 4935 |
|
// Cleanup hanging transaction on error |
| 4936 |
|
$repository->rollback(); |
| 4937 |
|
throw $e; |
| 4938 |
|
} |
| 4939 |
|
|
| 4940 |
|
// This array will contain no element |
| 4941 |
|
$drafts = $contentService->loadContentDrafts(); |
| 4942 |
|
/* END: Use Case */ |
| 4943 |
|
|
| 4944 |
|
$this->assertSame([], $drafts); |
| 4945 |
|
} |
| 4946 |
|
|
| 4947 |
|
/** |
| 4948 |
|
* Test for the deleteContent() method. |
|
@@ 4954-4989 (lines=36) @@
|
| 4951 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testDeleteContent |
| 4952 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4953 |
|
*/ |
| 4954 |
|
public function testDeleteContentInTransactionWithRollback() |
| 4955 |
|
{ |
| 4956 |
|
$repository = $this->getRepository(); |
| 4957 |
|
|
| 4958 |
|
$contentId = $this->generateId('object', 11); |
| 4959 |
|
/* BEGIN: Use Case */ |
| 4960 |
|
// $contentId is the ID of the "Members" user group in an eZ Publish |
| 4961 |
|
// demo installation |
| 4962 |
|
|
| 4963 |
|
// Get content service |
| 4964 |
|
$contentService = $repository->getContentService(); |
| 4965 |
|
|
| 4966 |
|
// Load a ContentInfo instance |
| 4967 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 4968 |
|
|
| 4969 |
|
// Start a new transaction |
| 4970 |
|
$repository->beginTransaction(); |
| 4971 |
|
|
| 4972 |
|
try { |
| 4973 |
|
// Delete content object |
| 4974 |
|
$contentService->deleteContent($contentInfo); |
| 4975 |
|
} catch (Exception $e) { |
| 4976 |
|
// Cleanup hanging transaction on error |
| 4977 |
|
$repository->rollback(); |
| 4978 |
|
throw $e; |
| 4979 |
|
} |
| 4980 |
|
|
| 4981 |
|
// Rollback all changes |
| 4982 |
|
$repository->rollback(); |
| 4983 |
|
|
| 4984 |
|
// This call will return the original content object |
| 4985 |
|
$contentInfo = $contentService->loadContentInfo($contentId); |
| 4986 |
|
/* END: Use Case */ |
| 4987 |
|
|
| 4988 |
|
$this->assertEquals($contentId, $contentInfo->id); |
| 4989 |
|
} |
| 4990 |
|
|
| 4991 |
|
/** |
| 4992 |
|
* Test for the deleteContent() method. |