| @@ 595-607 (lines=13) @@ | ||
| 592 | * |
|
| 593 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 594 | */ |
|
| 595 | public function testFindContentFieldCriterion() |
|
| 596 | { |
|
| 597 | $this->createKeywordContent(); |
|
| 598 | $repository = $this->getRepository(); |
|
| 599 | ||
| 600 | $criterion = new Criterion\Field('tags', Criterion\Operator::IN, ['foo']); |
|
| 601 | $query = new Query(['query' => $criterion]); |
|
| 602 | ||
| 603 | $searchService = $repository->getSearchService(); |
|
| 604 | $searchResult = $searchService->findContent($query); |
|
| 605 | ||
| 606 | $this->assertEquals(1, $searchResult->totalCount); |
|
| 607 | } |
|
| 608 | } |
|
| 609 | ||
| @@ 95-112 (lines=18) @@ | ||
| 92 | * |
|
| 93 | * @depends testFindContentInfoFullTextIsSearchable |
|
| 94 | */ |
|
| 95 | public function testFindContentInfoFullTextIsNotSearchable() |
|
| 96 | { |
|
| 97 | $searchTerm = 'pamplemousse'; |
|
| 98 | $this->createFullTextIsSearchableContent($searchTerm, false); |
|
| 99 | ||
| 100 | $repository = $this->getRepository(); |
|
| 101 | $searchService = $repository->getSearchService(); |
|
| 102 | ||
| 103 | $query = new Query( |
|
| 104 | [ |
|
| 105 | 'query' => new Criterion\FullText($searchTerm), |
|
| 106 | ] |
|
| 107 | ); |
|
| 108 | ||
| 109 | $searchResult = $searchService->findContentInfo($query); |
|
| 110 | ||
| 111 | $this->assertEquals(0, $searchResult->totalCount); |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Test that indexing full text data depends on the isSearchable flag on the field definition. |
|
| @@ 119-135 (lines=17) @@ | ||
| 116 | * |
|
| 117 | * @depends testFindLocationsFullTextIsSearchable |
|
| 118 | */ |
|
| 119 | public function testFindLocationsFullTextIsNotSearchable() |
|
| 120 | { |
|
| 121 | $searchTerm = 'pamplemousse'; |
|
| 122 | ||
| 123 | $repository = $this->getRepository(false); |
|
| 124 | $searchService = $repository->getSearchService(); |
|
| 125 | ||
| 126 | $query = new LocationQuery( |
|
| 127 | [ |
|
| 128 | 'query' => new Criterion\FullText($searchTerm), |
|
| 129 | ] |
|
| 130 | ); |
|
| 131 | ||
| 132 | $searchResult = $searchService->findLocations($query); |
|
| 133 | ||
| 134 | $this->assertEquals(0, $searchResult->totalCount); |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * Creates Content for testing full text search depending on the isSearchable flag. |
|
| @@ 1386-1404 (lines=19) @@ | ||
| 1383 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1384 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 1385 | */ |
|
| 1386 | public function testFieldCollectionContainsNoMatch() |
|
| 1387 | { |
|
| 1388 | $this->createMultipleCountriesContent(); |
|
| 1389 | $query = new Query( |
|
| 1390 | [ |
|
| 1391 | 'query' => new Criterion\Field( |
|
| 1392 | 'countries', |
|
| 1393 | Criterion\Operator::CONTAINS, |
|
| 1394 | 'Netherlands Antilles' |
|
| 1395 | ), |
|
| 1396 | ] |
|
| 1397 | ); |
|
| 1398 | ||
| 1399 | $repository = $this->getRepository(); |
|
| 1400 | $searchService = $repository->getSearchService(); |
|
| 1401 | $result = $searchService->findContent($query); |
|
| 1402 | ||
| 1403 | $this->assertEquals(0, $result->totalCount); |
|
| 1404 | } |
|
| 1405 | ||
| 1406 | /** |
|
| 1407 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| @@ 305-323 (lines=19) @@ | ||
| 302 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 303 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 304 | */ |
|
| 305 | public function testFieldCollectionContainsNoMatch() |
|
| 306 | { |
|
| 307 | $this->createMultipleCountriesContent(); |
|
| 308 | $query = new LocationQuery( |
|
| 309 | [ |
|
| 310 | 'query' => new Criterion\Field( |
|
| 311 | 'countries', |
|
| 312 | Criterion\Operator::CONTAINS, |
|
| 313 | 'Netherlands Antilles' |
|
| 314 | ), |
|
| 315 | ] |
|
| 316 | ); |
|
| 317 | ||
| 318 | $repository = $this->getRepository(); |
|
| 319 | $searchService = $repository->getSearchService(); |
|
| 320 | $result = $searchService->findLocations($query); |
|
| 321 | ||
| 322 | $this->assertEquals(0, $result->totalCount); |
|
| 323 | } |
|
| 324 | ||
| 325 | /** |
|
| 326 | * @covers \eZ\Publish\API\Repository\SearchService::findLocations |
|