| @@ 219-242 (lines=24) @@ | ||
| 216 | * |
|
| 217 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 218 | */ |
|
| 219 | public function testFieldIsNotEmptyInLocation() |
|
| 220 | { |
|
| 221 | $testContents = $this->createMovieContent(); |
|
| 222 | ||
| 223 | $query = new LocationQuery( |
|
| 224 | [ |
|
| 225 | 'query' => new Criterion\IsFieldEmpty( |
|
| 226 | 'subtitle', |
|
| 227 | false |
|
| 228 | ), |
|
| 229 | ] |
|
| 230 | ); |
|
| 231 | ||
| 232 | $repository = $this->getRepository(); |
|
| 233 | $searchService = $repository->getSearchService(); |
|
| 234 | $result = $searchService->findLocations($query); |
|
| 235 | ||
| 236 | $this->assertEquals(1, $result->totalCount); |
|
| 237 | ||
| 238 | $this->assertEquals( |
|
| 239 | $testContents[2]->contentInfo->mainLocationId, |
|
| 240 | $result->searchHits[0]->valueObject->id |
|
| 241 | ); |
|
| 242 | } |
|
| 243 | ||
| 244 | /** |
|
| 245 | * Test for the findLocations() method. |
|
| @@ 249-272 (lines=24) @@ | ||
| 246 | * |
|
| 247 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 248 | */ |
|
| 249 | public function testFieldCollectionContains() |
|
| 250 | { |
|
| 251 | $testContent = $this->createMultipleCountriesContent(); |
|
| 252 | ||
| 253 | $query = new LocationQuery( |
|
| 254 | [ |
|
| 255 | 'query' => new Criterion\Field( |
|
| 256 | 'countries', |
|
| 257 | Criterion\Operator::CONTAINS, |
|
| 258 | 'Belgium' |
|
| 259 | ), |
|
| 260 | ] |
|
| 261 | ); |
|
| 262 | ||
| 263 | $repository = $this->getRepository(); |
|
| 264 | $searchService = $repository->getSearchService(); |
|
| 265 | $result = $searchService->findLocations($query); |
|
| 266 | ||
| 267 | $this->assertEquals(1, $result->totalCount); |
|
| 268 | $this->assertEquals( |
|
| 269 | $testContent->contentInfo->mainLocationId, |
|
| 270 | $result->searchHits[0]->valueObject->id |
|
| 271 | ); |
|
| 272 | } |
|
| 273 | ||
| 274 | /** |
|
| 275 | * Test for the findLocations() method. |
|
| @@ 1323-1345 (lines=23) @@ | ||
| 1320 | * |
|
| 1321 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1322 | */ |
|
| 1323 | public function testFieldIsNotEmpty() |
|
| 1324 | { |
|
| 1325 | $testContents = $this->createMovieContent(); |
|
| 1326 | ||
| 1327 | $query = new Query( |
|
| 1328 | [ |
|
| 1329 | 'query' => new Criterion\IsFieldEmpty( |
|
| 1330 | 'subtitle', |
|
| 1331 | false |
|
| 1332 | ), |
|
| 1333 | ] |
|
| 1334 | ); |
|
| 1335 | ||
| 1336 | $repository = $this->getRepository(); |
|
| 1337 | $searchService = $repository->getSearchService(); |
|
| 1338 | $result = $searchService->findContent($query, ['eng-GB']); |
|
| 1339 | ||
| 1340 | $this->assertEquals(1, $result->totalCount); |
|
| 1341 | $this->assertEquals( |
|
| 1342 | $testContents[2]->id, |
|
| 1343 | $result->searchHits[0]->valueObject->id |
|
| 1344 | ); |
|
| 1345 | } |
|
| 1346 | ||
| 1347 | /** |
|
| 1348 | * Test for the findContent() method. |
|
| @@ 1352-1375 (lines=24) @@ | ||
| 1349 | * |
|
| 1350 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1351 | */ |
|
| 1352 | public function testFieldCollectionContains() |
|
| 1353 | { |
|
| 1354 | $testContent = $this->createMultipleCountriesContent(); |
|
| 1355 | ||
| 1356 | $query = new Query( |
|
| 1357 | [ |
|
| 1358 | 'query' => new Criterion\Field( |
|
| 1359 | 'countries', |
|
| 1360 | Criterion\Operator::CONTAINS, |
|
| 1361 | 'Belgium' |
|
| 1362 | ), |
|
| 1363 | ] |
|
| 1364 | ); |
|
| 1365 | ||
| 1366 | $repository = $this->getRepository(); |
|
| 1367 | $searchService = $repository->getSearchService(); |
|
| 1368 | $result = $searchService->findContent($query); |
|
| 1369 | ||
| 1370 | $this->assertEquals(1, $result->totalCount); |
|
| 1371 | $this->assertEquals( |
|
| 1372 | $testContent->id, |
|
| 1373 | $result->searchHits[0]->valueObject->id |
|
| 1374 | ); |
|
| 1375 | } |
|
| 1376 | ||
| 1377 | /** |
|
| 1378 | * Test for the findContent() method. |
|