|
@@ 4550-4582 (lines=33) @@
|
| 4547 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4548 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4549 |
|
*/ |
| 4550 |
|
public function testDeleteVersionInTransactionWithRollback() |
| 4551 |
|
{ |
| 4552 |
|
$repository = $this->getRepository(); |
| 4553 |
|
|
| 4554 |
|
$contentId = $this->generateId('object', 12); |
| 4555 |
|
/* BEGIN: Use Case */ |
| 4556 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4557 |
|
|
| 4558 |
|
// Start a new transaction |
| 4559 |
|
$repository->beginTransaction(); |
| 4560 |
|
|
| 4561 |
|
try { |
| 4562 |
|
// Create a new draft |
| 4563 |
|
$draft = $this->contentService->createContentDraft( |
| 4564 |
|
$this->contentService->loadContentInfo($contentId) |
| 4565 |
|
); |
| 4566 |
|
|
| 4567 |
|
$this->contentService->deleteVersion($draft->getVersionInfo()); |
| 4568 |
|
} catch (Exception $e) { |
| 4569 |
|
// Cleanup hanging transaction on error |
| 4570 |
|
$repository->rollback(); |
| 4571 |
|
throw $e; |
| 4572 |
|
} |
| 4573 |
|
|
| 4574 |
|
// Rollback all changes. |
| 4575 |
|
$repository->rollback(); |
| 4576 |
|
|
| 4577 |
|
// This array will be empty |
| 4578 |
|
$drafts = $this->contentService->loadContentDrafts(); |
| 4579 |
|
/* END: Use Case */ |
| 4580 |
|
|
| 4581 |
|
$this->assertSame([], $drafts); |
| 4582 |
|
} |
| 4583 |
|
|
| 4584 |
|
/** |
| 4585 |
|
* Test for the deleteVersion() method. |
|
@@ 4592-4624 (lines=33) @@
|
| 4589 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4590 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4591 |
|
*/ |
| 4592 |
|
public function testDeleteVersionInTransactionWithCommit() |
| 4593 |
|
{ |
| 4594 |
|
$repository = $this->getRepository(); |
| 4595 |
|
|
| 4596 |
|
$contentId = $this->generateId('object', 12); |
| 4597 |
|
/* BEGIN: Use Case */ |
| 4598 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4599 |
|
|
| 4600 |
|
// Start a new transaction |
| 4601 |
|
$repository->beginTransaction(); |
| 4602 |
|
|
| 4603 |
|
try { |
| 4604 |
|
// Create a new draft |
| 4605 |
|
$draft = $this->contentService->createContentDraft( |
| 4606 |
|
$this->contentService->loadContentInfo($contentId) |
| 4607 |
|
); |
| 4608 |
|
|
| 4609 |
|
$this->contentService->deleteVersion($draft->getVersionInfo()); |
| 4610 |
|
|
| 4611 |
|
// Commit all changes. |
| 4612 |
|
$repository->commit(); |
| 4613 |
|
} catch (Exception $e) { |
| 4614 |
|
// Cleanup hanging transaction on error |
| 4615 |
|
$repository->rollback(); |
| 4616 |
|
throw $e; |
| 4617 |
|
} |
| 4618 |
|
|
| 4619 |
|
// This array will contain no element |
| 4620 |
|
$drafts = $this->contentService->loadContentDrafts(); |
| 4621 |
|
/* END: Use Case */ |
| 4622 |
|
|
| 4623 |
|
$this->assertSame([], $drafts); |
| 4624 |
|
} |
| 4625 |
|
|
| 4626 |
|
/** |
| 4627 |
|
* Test for the deleteContent() method. |