| @@ 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. |
|
| @@ 594-606 (lines=13) @@ | ||
| 591 | * |
|
| 592 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 593 | */ |
|
| 594 | public function testFindContentFieldCriterion() |
|
| 595 | { |
|
| 596 | $this->createKeywordContent(); |
|
| 597 | $repository = $this->getRepository(); |
|
| 598 | ||
| 599 | $criterion = new Criterion\Field('tags', Criterion\Operator::IN, ['foo']); |
|
| 600 | $query = new Query(['query' => $criterion]); |
|
| 601 | ||
| 602 | $searchService = $repository->getSearchService(); |
|
| 603 | $searchResult = $searchService->findContent($query); |
|
| 604 | ||
| 605 | $this->assertEquals(1, $searchResult->totalCount); |
|
| 606 | } |
|
| 607 | } |
|
| 608 | ||
| @@ 280-298 (lines=19) @@ | ||
| 277 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 278 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 279 | */ |
|
| 280 | public function testFieldCollectionContainsNoMatch() |
|
| 281 | { |
|
| 282 | $this->createMultipleCountriesContent(); |
|
| 283 | $query = new LocationQuery( |
|
| 284 | [ |
|
| 285 | 'query' => new Criterion\Field( |
|
| 286 | 'countries', |
|
| 287 | Criterion\Operator::CONTAINS, |
|
| 288 | 'Netherlands Antilles' |
|
| 289 | ), |
|
| 290 | ] |
|
| 291 | ); |
|
| 292 | ||
| 293 | $repository = $this->getRepository(); |
|
| 294 | $searchService = $repository->getSearchService(); |
|
| 295 | $result = $searchService->findLocations($query); |
|
| 296 | ||
| 297 | $this->assertEquals(0, $result->totalCount); |
|
| 298 | } |
|
| 299 | ||
| 300 | /** |
|
| 301 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| @@ 1383-1401 (lines=19) @@ | ||
| 1380 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1381 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 1382 | */ |
|
| 1383 | public function testFieldCollectionContainsNoMatch() |
|
| 1384 | { |
|
| 1385 | $this->createMultipleCountriesContent(); |
|
| 1386 | $query = new Query( |
|
| 1387 | [ |
|
| 1388 | 'query' => new Criterion\Field( |
|
| 1389 | 'countries', |
|
| 1390 | Criterion\Operator::CONTAINS, |
|
| 1391 | 'Netherlands Antilles' |
|
| 1392 | ), |
|
| 1393 | ] |
|
| 1394 | ); |
|
| 1395 | ||
| 1396 | $repository = $this->getRepository(); |
|
| 1397 | $searchService = $repository->getSearchService(); |
|
| 1398 | $result = $searchService->findContent($query); |
|
| 1399 | ||
| 1400 | $this->assertEquals(0, $result->totalCount); |
|
| 1401 | } |
|
| 1402 | ||
| 1403 | /** |
|
| 1404 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|