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