| @@ 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 | ||
| @@ 88-105 (lines=18) @@ | ||
| 85 | * |
|
| 86 | * @depends testFindContentInfoFullTextIsSearchable |
|
| 87 | */ |
|
| 88 | public function testFindContentInfoFullTextIsNotSearchable() |
|
| 89 | { |
|
| 90 | $searchTerm = 'pamplemousse'; |
|
| 91 | $this->createFullTextIsSearchableContent($searchTerm, false); |
|
| 92 | ||
| 93 | $repository = $this->getRepository(); |
|
| 94 | $searchService = $repository->getSearchService(); |
|
| 95 | ||
| 96 | $query = new Query( |
|
| 97 | [ |
|
| 98 | 'query' => new Criterion\FullText($searchTerm), |
|
| 99 | ] |
|
| 100 | ); |
|
| 101 | ||
| 102 | $searchResult = $searchService->findContentInfo($query); |
|
| 103 | ||
| 104 | $this->assertEquals(0, $searchResult->totalCount); |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| 108 | * Test that indexing full text data depends on the isSearchable flag on the field definition. |
|
| @@ 112-128 (lines=17) @@ | ||
| 109 | * |
|
| 110 | * @depends testFindLocationsFullTextIsSearchable |
|
| 111 | */ |
|
| 112 | public function testFindLocationsFullTextIsNotSearchable() |
|
| 113 | { |
|
| 114 | $searchTerm = 'pamplemousse'; |
|
| 115 | ||
| 116 | $repository = $this->getRepository(false); |
|
| 117 | $searchService = $repository->getSearchService(); |
|
| 118 | ||
| 119 | $query = new LocationQuery( |
|
| 120 | [ |
|
| 121 | 'query' => new Criterion\FullText($searchTerm), |
|
| 122 | ] |
|
| 123 | ); |
|
| 124 | ||
| 125 | $searchResult = $searchService->findLocations($query); |
|
| 126 | ||
| 127 | $this->assertEquals(0, $searchResult->totalCount); |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Creates Content for testing full text search depending on the isSearchable flag. |
|
| @@ 129-147 (lines=19) @@ | ||
| 126 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 127 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 128 | */ |
|
| 129 | public function testFieldCollectionContainsNoMatch() |
|
| 130 | { |
|
| 131 | $this->createMultipleCountriesContent(); |
|
| 132 | $query = new LocationQuery( |
|
| 133 | array( |
|
| 134 | 'query' => new Criterion\Field( |
|
| 135 | 'countries', |
|
| 136 | Criterion\Operator::CONTAINS, |
|
| 137 | 'Netherlands Antilles' |
|
| 138 | ), |
|
| 139 | ) |
|
| 140 | ); |
|
| 141 | ||
| 142 | $repository = $this->getRepository(); |
|
| 143 | $searchService = $repository->getSearchService(); |
|
| 144 | $result = $searchService->findLocations($query); |
|
| 145 | ||
| 146 | $this->assertEquals(0, $result->totalCount); |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| @@ 1216-1234 (lines=19) @@ | ||
| 1213 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1214 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
|
| 1215 | */ |
|
| 1216 | public function testFieldCollectionContainsNoMatch() |
|
| 1217 | { |
|
| 1218 | $this->createMultipleCountriesContent(); |
|
| 1219 | $query = new Query( |
|
| 1220 | array( |
|
| 1221 | 'query' => new Criterion\Field( |
|
| 1222 | 'countries', |
|
| 1223 | Criterion\Operator::CONTAINS, |
|
| 1224 | 'Netherlands Antilles' |
|
| 1225 | ), |
|
| 1226 | ) |
|
| 1227 | ); |
|
| 1228 | ||
| 1229 | $repository = $this->getRepository(); |
|
| 1230 | $searchService = $repository->getSearchService(); |
|
| 1231 | $result = $searchService->findContent($query); |
|
| 1232 | ||
| 1233 | $this->assertEquals(0, $result->totalCount); |
|
| 1234 | } |
|
| 1235 | ||
| 1236 | /** |
|
| 1237 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|