|
@@ 626-653 (lines=28) @@
|
| 623 |
|
* @see \eZ\Publish\API\Repository\TrashService::findTrashItems() |
| 624 |
|
* @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash |
| 625 |
|
*/ |
| 626 |
|
public function testFindTrashItems() |
| 627 |
|
{ |
| 628 |
|
$repository = $this->getRepository(); |
| 629 |
|
$trashService = $repository->getTrashService(); |
| 630 |
|
|
| 631 |
|
/* BEGIN: Use Case */ |
| 632 |
|
$this->createTrashItem(); |
| 633 |
|
|
| 634 |
|
// Create a search query for all trashed items |
| 635 |
|
$query = new Query(); |
| 636 |
|
$query->filter = new Criterion\LogicalAnd( |
| 637 |
|
array( |
| 638 |
|
new Criterion\Field('title', Criterion\Operator::LIKE, '*'), |
| 639 |
|
) |
| 640 |
|
); |
| 641 |
|
|
| 642 |
|
// Load all trashed locations |
| 643 |
|
$searchResult = $trashService->findTrashItems($query); |
| 644 |
|
/* END: Use Case */ |
| 645 |
|
|
| 646 |
|
$this->assertInstanceOf( |
| 647 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\SearchResult', |
| 648 |
|
$searchResult |
| 649 |
|
); |
| 650 |
|
|
| 651 |
|
// 4 trashed locations from the sub tree |
| 652 |
|
$this->assertEquals(4, $searchResult->count); |
| 653 |
|
} |
| 654 |
|
|
| 655 |
|
/** |
| 656 |
|
* Test for the findTrashItems() method. |
|
@@ 702-726 (lines=25) @@
|
| 699 |
|
* @see \eZ\Publish\API\Repository\TrashService::emptyTrash() |
| 700 |
|
* @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testFindTrashItems |
| 701 |
|
*/ |
| 702 |
|
public function testEmptyTrash() |
| 703 |
|
{ |
| 704 |
|
$repository = $this->getRepository(); |
| 705 |
|
$trashService = $repository->getTrashService(); |
| 706 |
|
|
| 707 |
|
/* BEGIN: Use Case */ |
| 708 |
|
$this->createTrashItem(); |
| 709 |
|
|
| 710 |
|
// Empty the trash |
| 711 |
|
$trashService->emptyTrash(); |
| 712 |
|
|
| 713 |
|
// Create a search query for all trashed items |
| 714 |
|
$query = new Query(); |
| 715 |
|
$query->filter = new Criterion\LogicalAnd( |
| 716 |
|
array( |
| 717 |
|
new Criterion\Field('title', Criterion\Operator::LIKE, '*'), |
| 718 |
|
) |
| 719 |
|
); |
| 720 |
|
|
| 721 |
|
// Load all trashed locations, search result should be empty |
| 722 |
|
$searchResult = $trashService->findTrashItems($query); |
| 723 |
|
/* END: Use Case */ |
| 724 |
|
|
| 725 |
|
$this->assertEquals(0, $searchResult->count); |
| 726 |
|
} |
| 727 |
|
|
| 728 |
|
/** |
| 729 |
|
* Test for the deleteTrashItem() method. |