|
@@ 4450-4482 (lines=33) @@
|
| 4447 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4448 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4449 |
|
*/ |
| 4450 |
|
public function testDeleteVersionInTransactionWithRollback() |
| 4451 |
|
{ |
| 4452 |
|
$repository = $this->getRepository(); |
| 4453 |
|
|
| 4454 |
|
$contentId = $this->generateId('object', 12); |
| 4455 |
|
/* BEGIN: Use Case */ |
| 4456 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4457 |
|
|
| 4458 |
|
// Start a new transaction |
| 4459 |
|
$repository->beginTransaction(); |
| 4460 |
|
|
| 4461 |
|
try { |
| 4462 |
|
// Create a new draft |
| 4463 |
|
$draft = $this->contentService->createContentDraft( |
| 4464 |
|
$this->contentService->loadContentInfo($contentId) |
| 4465 |
|
); |
| 4466 |
|
|
| 4467 |
|
$this->contentService->deleteVersion($draft->getVersionInfo()); |
| 4468 |
|
} catch (Exception $e) { |
| 4469 |
|
// Cleanup hanging transaction on error |
| 4470 |
|
$repository->rollback(); |
| 4471 |
|
throw $e; |
| 4472 |
|
} |
| 4473 |
|
|
| 4474 |
|
// Rollback all changes. |
| 4475 |
|
$repository->rollback(); |
| 4476 |
|
|
| 4477 |
|
// This array will be empty |
| 4478 |
|
$drafts = $this->contentService->loadContentDrafts(); |
| 4479 |
|
/* END: Use Case */ |
| 4480 |
|
|
| 4481 |
|
$this->assertSame([], $drafts); |
| 4482 |
|
} |
| 4483 |
|
|
| 4484 |
|
/** |
| 4485 |
|
* Test for the deleteVersion() method. |
|
@@ 4492-4524 (lines=33) @@
|
| 4489 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentInfo |
| 4490 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentDrafts |
| 4491 |
|
*/ |
| 4492 |
|
public function testDeleteVersionInTransactionWithCommit() |
| 4493 |
|
{ |
| 4494 |
|
$repository = $this->getRepository(); |
| 4495 |
|
|
| 4496 |
|
$contentId = $this->generateId('object', 12); |
| 4497 |
|
/* BEGIN: Use Case */ |
| 4498 |
|
// $contentId is the ID of the "Administrator users" user group |
| 4499 |
|
|
| 4500 |
|
// Start a new transaction |
| 4501 |
|
$repository->beginTransaction(); |
| 4502 |
|
|
| 4503 |
|
try { |
| 4504 |
|
// Create a new draft |
| 4505 |
|
$draft = $this->contentService->createContentDraft( |
| 4506 |
|
$this->contentService->loadContentInfo($contentId) |
| 4507 |
|
); |
| 4508 |
|
|
| 4509 |
|
$this->contentService->deleteVersion($draft->getVersionInfo()); |
| 4510 |
|
|
| 4511 |
|
// Commit all changes. |
| 4512 |
|
$repository->commit(); |
| 4513 |
|
} catch (Exception $e) { |
| 4514 |
|
// Cleanup hanging transaction on error |
| 4515 |
|
$repository->rollback(); |
| 4516 |
|
throw $e; |
| 4517 |
|
} |
| 4518 |
|
|
| 4519 |
|
// This array will contain no element |
| 4520 |
|
$drafts = $this->contentService->loadContentDrafts(); |
| 4521 |
|
/* END: Use Case */ |
| 4522 |
|
|
| 4523 |
|
$this->assertSame([], $drafts); |
| 4524 |
|
} |
| 4525 |
|
|
| 4526 |
|
/** |
| 4527 |
|
* Test for the deleteContent() method. |