| @@ 97-114 (lines=18) @@ | ||
| 94 | * |
|
| 95 | * @depends testFindContentInfoFullTextIsSearchable |
|
| 96 | */ |
|
| 97 | public function testFindContentInfoFullTextIsNotSearchable() |
|
| 98 | { |
|
| 99 | $searchTerm = 'pamplemousse'; |
|
| 100 | $this->createFullTextIsSearchableContent($searchTerm, false); |
|
| 101 | ||
| 102 | $repository = $this->getRepository(); |
|
| 103 | $searchService = $repository->getSearchService(); |
|
| 104 | ||
| 105 | $query = new Query( |
|
| 106 | [ |
|
| 107 | 'query' => new Criterion\FullText($searchTerm), |
|
| 108 | ] |
|
| 109 | ); |
|
| 110 | ||
| 111 | $searchResult = $searchService->findContentInfo($query); |
|
| 112 | ||
| 113 | $this->assertEquals(0, $searchResult->totalCount); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Test that indexing full text data depends on the isSearchable flag on the field definition. |
|
| @@ 121-137 (lines=17) @@ | ||
| 118 | * |
|
| 119 | * @depends testFindLocationsFullTextIsSearchable |
|
| 120 | */ |
|
| 121 | public function testFindLocationsFullTextIsNotSearchable() |
|
| 122 | { |
|
| 123 | $searchTerm = 'pamplemousse'; |
|
| 124 | ||
| 125 | $repository = $this->getRepository(false); |
|
| 126 | $searchService = $repository->getSearchService(); |
|
| 127 | ||
| 128 | $query = new LocationQuery( |
|
| 129 | [ |
|
| 130 | 'query' => new Criterion\FullText($searchTerm), |
|
| 131 | ] |
|
| 132 | ); |
|
| 133 | ||
| 134 | $searchResult = $searchService->findLocations($query); |
|
| 135 | ||
| 136 | $this->assertEquals(0, $searchResult->totalCount); |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * Creates Content for testing full text search depending on the isSearchable flag. |
|
| @@ 125-143 (lines=19) @@ | ||
| 122 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 123 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 124 | */ |
|
| 125 | public function testFieldCollectionContainsNoMatch() |
|
| 126 | { |
|
| 127 | $this->createMultipleCountriesContent(); |
|
| 128 | $query = new LocationQuery( |
|
| 129 | array( |
|
| 130 | 'query' => new Criterion\Field( |
|
| 131 | 'countries', |
|
| 132 | Criterion\Operator::CONTAINS, |
|
| 133 | 'Netherlands Antilles' |
|
| 134 | ), |
|
| 135 | ) |
|
| 136 | ); |
|
| 137 | ||
| 138 | $repository = $this->getRepository(); |
|
| 139 | $searchService = $repository->getSearchService(); |
|
| 140 | $result = $searchService->findLocations($query); |
|
| 141 | ||
| 142 | $this->assertEquals(0, $result->totalCount); |
|
| 143 | } |
|
| 144 | ||
| 145 | /** |
|
| 146 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| @@ 1214-1232 (lines=19) @@ | ||
| 1211 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1212 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 1213 | */ |
|
| 1214 | public function testFieldCollectionContainsNoMatch() |
|
| 1215 | { |
|
| 1216 | $this->createMultipleCountriesContent(); |
|
| 1217 | $query = new Query( |
|
| 1218 | array( |
|
| 1219 | 'query' => new Criterion\Field( |
|
| 1220 | 'countries', |
|
| 1221 | Criterion\Operator::CONTAINS, |
|
| 1222 | 'Netherlands Antilles' |
|
| 1223 | ), |
|
| 1224 | ) |
|
| 1225 | ); |
|
| 1226 | ||
| 1227 | $repository = $this->getRepository(); |
|
| 1228 | $searchService = $repository->getSearchService(); |
|
| 1229 | $result = $searchService->findContent($query); |
|
| 1230 | ||
| 1231 | $this->assertEquals(0, $result->totalCount); |
|
| 1232 | } |
|
| 1233 | ||
| 1234 | /** |
|
| 1235 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| @@ 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 findTrashItems() method. |
|
| @@ 601-625 (lines=25) @@ | ||
| 598 | * @see \eZ\Publish\API\Repository\TrashService::emptyTrash() |
|
| 599 | * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testFindTrashItems |
|
| 600 | */ |
|
| 601 | public function testEmptyTrash() |
|
| 602 | { |
|
| 603 | $repository = $this->getRepository(); |
|
| 604 | $trashService = $repository->getTrashService(); |
|
| 605 | ||
| 606 | /* BEGIN: Use Case */ |
|
| 607 | $this->createTrashItem(); |
|
| 608 | ||
| 609 | // Empty the trash |
|
| 610 | $trashService->emptyTrash(); |
|
| 611 | ||
| 612 | // Create a search query for all trashed items |
|
| 613 | $query = new Query(); |
|
| 614 | $query->filter = new Criterion\LogicalAnd( |
|
| 615 | array( |
|
| 616 | new Criterion\Field('title', Criterion\Operator::LIKE, '*'), |
|
| 617 | ) |
|
| 618 | ); |
|
| 619 | ||
| 620 | // Load all trashed locations, search result should be empty |
|
| 621 | $searchResult = $trashService->findTrashItems($query); |
|
| 622 | /* END: Use Case */ |
|
| 623 | ||
| 624 | $this->assertEquals(0, $searchResult->count); |
|
| 625 | } |
|
| 626 | ||
| 627 | /** |
|
| 628 | * Test for the deleteTrashItem() method. |
|