|
@@ 525-552 (lines=28) @@
|
| 522 |
|
* @see \eZ\Publish\API\Repository\TrashService::findTrashItems() |
| 523 |
|
* @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash |
| 524 |
|
*/ |
| 525 |
|
public function testFindTrashItems() |
| 526 |
|
{ |
| 527 |
|
$repository = $this->getRepository(); |
| 528 |
|
$trashService = $repository->getTrashService(); |
| 529 |
|
|
| 530 |
|
/* BEGIN: Use Case */ |
| 531 |
|
$this->createTrashItem(); |
| 532 |
|
|
| 533 |
|
// Create a search query for all trashed items |
| 534 |
|
$query = new Query(); |
| 535 |
|
$query->filter = new Criterion\LogicalAnd( |
| 536 |
|
array( |
| 537 |
|
new Criterion\Field('title', Criterion\Operator::LIKE, '*'), |
| 538 |
|
) |
| 539 |
|
); |
| 540 |
|
|
| 541 |
|
// Load all trashed locations |
| 542 |
|
$searchResult = $trashService->findTrashItems($query); |
| 543 |
|
/* END: Use Case */ |
| 544 |
|
|
| 545 |
|
$this->assertInstanceOf( |
| 546 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\SearchResult', |
| 547 |
|
$searchResult |
| 548 |
|
); |
| 549 |
|
|
| 550 |
|
// 4 trashed locations from the sub tree |
| 551 |
|
$this->assertEquals(4, $searchResult->count); |
| 552 |
|
} |
| 553 |
|
|
| 554 |
|
/** |
| 555 |
|
* Test for the emptyTrash() method. |
|
@@ 560-584 (lines=25) @@
|
| 557 |
|
* @see \eZ\Publish\API\Repository\TrashService::emptyTrash() |
| 558 |
|
* @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testFindTrashItems |
| 559 |
|
*/ |
| 560 |
|
public function testEmptyTrash() |
| 561 |
|
{ |
| 562 |
|
$repository = $this->getRepository(); |
| 563 |
|
$trashService = $repository->getTrashService(); |
| 564 |
|
|
| 565 |
|
/* BEGIN: Use Case */ |
| 566 |
|
$this->createTrashItem(); |
| 567 |
|
|
| 568 |
|
// Empty the trash |
| 569 |
|
$trashService->emptyTrash(); |
| 570 |
|
|
| 571 |
|
// Create a search query for all trashed items |
| 572 |
|
$query = new Query(); |
| 573 |
|
$query->filter = new Criterion\LogicalAnd( |
| 574 |
|
array( |
| 575 |
|
new Criterion\Field('title', Criterion\Operator::LIKE, '*'), |
| 576 |
|
) |
| 577 |
|
); |
| 578 |
|
|
| 579 |
|
// Load all trashed locations, search result should be empty |
| 580 |
|
$searchResult = $trashService->findTrashItems($query); |
| 581 |
|
/* END: Use Case */ |
| 582 |
|
|
| 583 |
|
$this->assertEquals(0, $searchResult->count); |
| 584 |
|
} |
| 585 |
|
|
| 586 |
|
/** |
| 587 |
|
* Test for the deleteTrashItem() method. |