| @@ 1326-1348 (lines=23) @@ | ||
| 1323 | * |
|
| 1324 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1325 | */ |
|
| 1326 | public function testFieldIsNotEmpty() |
|
| 1327 | { |
|
| 1328 | $testContents = $this->createMovieContent(); |
|
| 1329 | ||
| 1330 | $query = new Query( |
|
| 1331 | [ |
|
| 1332 | 'query' => new Criterion\IsFieldEmpty( |
|
| 1333 | 'subtitle', |
|
| 1334 | false |
|
| 1335 | ), |
|
| 1336 | ] |
|
| 1337 | ); |
|
| 1338 | ||
| 1339 | $repository = $this->getRepository(); |
|
| 1340 | $searchService = $repository->getSearchService(); |
|
| 1341 | $result = $searchService->findContent($query, ['eng-GB']); |
|
| 1342 | ||
| 1343 | $this->assertEquals(1, $result->totalCount); |
|
| 1344 | $this->assertEquals( |
|
| 1345 | $testContents[2]->id, |
|
| 1346 | $result->searchHits[0]->valueObject->id |
|
| 1347 | ); |
|
| 1348 | } |
|
| 1349 | ||
| 1350 | /** |
|
| 1351 | * Test for the findContent() method. |
|
| @@ 1355-1378 (lines=24) @@ | ||
| 1352 | * |
|
| 1353 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
|
| 1354 | */ |
|
| 1355 | public function testFieldCollectionContains() |
|
| 1356 | { |
|
| 1357 | $testContent = $this->createMultipleCountriesContent(); |
|
| 1358 | ||
| 1359 | $query = new Query( |
|
| 1360 | [ |
|
| 1361 | 'query' => new Criterion\Field( |
|
| 1362 | 'countries', |
|
| 1363 | Criterion\Operator::CONTAINS, |
|
| 1364 | 'Belgium' |
|
| 1365 | ), |
|
| 1366 | ] |
|
| 1367 | ); |
|
| 1368 | ||
| 1369 | $repository = $this->getRepository(); |
|
| 1370 | $searchService = $repository->getSearchService(); |
|
| 1371 | $result = $searchService->findContent($query); |
|
| 1372 | ||
| 1373 | $this->assertEquals(1, $result->totalCount); |
|
| 1374 | $this->assertEquals( |
|
| 1375 | $testContent->id, |
|
| 1376 | $result->searchHits[0]->valueObject->id |
|
| 1377 | ); |
|
| 1378 | } |
|
| 1379 | ||
| 1380 | /** |
|
| 1381 | * Test for the findContent() method. |
|
| @@ 244-267 (lines=24) @@ | ||
| 241 | * |
|
| 242 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 243 | */ |
|
| 244 | public function testFieldIsNotEmptyInLocation() |
|
| 245 | { |
|
| 246 | $testContents = $this->createMovieContent(); |
|
| 247 | ||
| 248 | $query = new LocationQuery( |
|
| 249 | [ |
|
| 250 | 'query' => new Criterion\IsFieldEmpty( |
|
| 251 | 'subtitle', |
|
| 252 | false |
|
| 253 | ), |
|
| 254 | ] |
|
| 255 | ); |
|
| 256 | ||
| 257 | $repository = $this->getRepository(); |
|
| 258 | $searchService = $repository->getSearchService(); |
|
| 259 | $result = $searchService->findLocations($query); |
|
| 260 | ||
| 261 | $this->assertEquals(1, $result->totalCount); |
|
| 262 | ||
| 263 | $this->assertEquals( |
|
| 264 | $testContents[2]->contentInfo->mainLocationId, |
|
| 265 | $result->searchHits[0]->valueObject->id |
|
| 266 | ); |
|
| 267 | } |
|
| 268 | ||
| 269 | /** |
|
| 270 | * Test for the findLocations() method. |
|
| @@ 274-297 (lines=24) @@ | ||
| 271 | * |
|
| 272 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
|
| 273 | */ |
|
| 274 | public function testFieldCollectionContains() |
|
| 275 | { |
|
| 276 | $testContent = $this->createMultipleCountriesContent(); |
|
| 277 | ||
| 278 | $query = new LocationQuery( |
|
| 279 | [ |
|
| 280 | 'query' => new Criterion\Field( |
|
| 281 | 'countries', |
|
| 282 | Criterion\Operator::CONTAINS, |
|
| 283 | 'Belgium' |
|
| 284 | ), |
|
| 285 | ] |
|
| 286 | ); |
|
| 287 | ||
| 288 | $repository = $this->getRepository(); |
|
| 289 | $searchService = $repository->getSearchService(); |
|
| 290 | $result = $searchService->findLocations($query); |
|
| 291 | ||
| 292 | $this->assertEquals(1, $result->totalCount); |
|
| 293 | $this->assertEquals( |
|
| 294 | $testContent->contentInfo->mainLocationId, |
|
| 295 | $result->searchHits[0]->valueObject->id |
|
| 296 | ); |
|
| 297 | } |
|
| 298 | ||
| 299 | /** |
|
| 300 | * Test for the findLocations() method. |
|
| @@ 328-350 (lines=23) @@ | ||
| 325 | /** |
|
| 326 | * @covers \eZ\Publish\API\Repository\SearchService::findLocations |
|
| 327 | */ |
|
| 328 | public function testNonPrintableUtf8Characters(): void |
|
| 329 | { |
|
| 330 | $folder = $this->createFolderWithNonPrintableUtf8Characters(); |
|
| 331 | $query = new LocationQuery( |
|
| 332 | [ |
|
| 333 | 'query' => new Criterion\Field( |
|
| 334 | 'name', |
|
| 335 | Criterion\Operator::EQ, |
|
| 336 | utf8_decode("Non\x09Printable\x0EFolder") |
|
| 337 | ), |
|
| 338 | ] |
|
| 339 | ); |
|
| 340 | ||
| 341 | $repository = $this->getRepository(); |
|
| 342 | $searchService = $repository->getSearchService(); |
|
| 343 | $result = $searchService->findLocations($query); |
|
| 344 | ||
| 345 | $this->assertEquals(1, $result->totalCount); |
|
| 346 | $this->assertEquals( |
|
| 347 | $folder->contentInfo->mainLocationId, |
|
| 348 | $result->searchHits[0]->valueObject->id |
|
| 349 | ); |
|
| 350 | } |
|
| 351 | ||
| 352 | /** |
|
| 353 | * @covers \eZ\Publish\API\Repository\SearchService::findLocations |
|