| @@ 1185-1208 (lines=24) @@ | ||
| 1182 | * |
|
| 1183 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1184 | */ |
|
| 1185 | public function testFieldCollectionContains() |
|
| 1186 | { |
|
| 1187 | $testContent = $this->createMultipleCountriesContent(); |
|
| 1188 | ||
| 1189 | $query = new Query( |
|
| 1190 | array( |
|
| 1191 | 'query' => new Criterion\Field( |
|
| 1192 | 'countries', |
|
| 1193 | Criterion\Operator::CONTAINS, |
|
| 1194 | 'Belgium' |
|
| 1195 | ), |
|
| 1196 | ) |
|
| 1197 | ); |
|
| 1198 | ||
| 1199 | $repository = $this->getRepository(); |
|
| 1200 | $searchService = $repository->getSearchService(); |
|
| 1201 | $result = $searchService->findContent($query); |
|
| 1202 | ||
| 1203 | $this->assertEquals(1, $result->totalCount); |
|
| 1204 | $this->assertEquals( |
|
| 1205 | $testContent->id, |
|
| 1206 | $result->searchHits[0]->valueObject->id |
|
| 1207 | ); |
|
| 1208 | } |
|
| 1209 | ||
| 1210 | /** |
|
| 1211 | * Test for the findContent() method. |
|
| @@ 61-81 (lines=21) @@ | ||
| 58 | * |
|
| 59 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
|
| 60 | */ |
|
| 61 | public function testFindLocationsFullTextIsSearchable(ContentInfo $contentInfo) |
|
| 62 | { |
|
| 63 | $searchTerm = 'pamplemousse'; |
|
| 64 | ||
| 65 | $repository = $this->getRepository(false); |
|
| 66 | $searchService = $repository->getSearchService(); |
|
| 67 | ||
| 68 | $query = new LocationQuery( |
|
| 69 | [ |
|
| 70 | 'query' => new Criterion\FullText($searchTerm), |
|
| 71 | ] |
|
| 72 | ); |
|
| 73 | ||
| 74 | $searchResult = $searchService->findLocations($query); |
|
| 75 | ||
| 76 | $this->assertEquals(1, $searchResult->totalCount); |
|
| 77 | $this->assertEquals( |
|
| 78 | $contentInfo->mainLocationId, |
|
| 79 | $searchResult->searchHits[0]->valueObject->id |
|
| 80 | ); |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Test that indexing full text data depends on the isSearchable flag on the field definition. |
|
| @@ 98-121 (lines=24) @@ | ||
| 95 | * |
|
| 96 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 97 | */ |
|
| 98 | public function testFieldCollectionContains() |
|
| 99 | { |
|
| 100 | $testContent = $this->createMultipleCountriesContent(); |
|
| 101 | ||
| 102 | $query = new LocationQuery( |
|
| 103 | array( |
|
| 104 | 'query' => new Criterion\Field( |
|
| 105 | 'countries', |
|
| 106 | Criterion\Operator::CONTAINS, |
|
| 107 | 'Belgium' |
|
| 108 | ), |
|
| 109 | ) |
|
| 110 | ); |
|
| 111 | ||
| 112 | $repository = $this->getRepository(); |
|
| 113 | $searchService = $repository->getSearchService(); |
|
| 114 | $result = $searchService->findLocations($query); |
|
| 115 | ||
| 116 | $this->assertEquals(1, $result->totalCount); |
|
| 117 | $this->assertEquals( |
|
| 118 | $testContent->contentInfo->mainLocationId, |
|
| 119 | $result->searchHits[0]->valueObject->id |
|
| 120 | ); |
|
| 121 | } |
|
| 122 | ||
| 123 | /** |
|
| 124 | * Test for the findLocations() method. |
|