|
@@ 331-404 (lines=74) @@
|
| 328 |
|
* @see \eZ\Publish\API\Repository\SearchService::findLocations() |
| 329 |
|
* @group maplocation |
| 330 |
|
*/ |
| 331 |
|
public function testMapLocationDistanceLessThanOrEqual() |
| 332 |
|
{ |
| 333 |
|
$contentType = $this->createTestPlaceContentType(); |
| 334 |
|
|
| 335 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 336 |
|
$repository = $this->getRepository(); |
| 337 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 338 |
|
$contentService = $repository->getContentService(); |
| 339 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 340 |
|
$locationCreateStruct = $repository->getLocationService()->newLocationCreateStruct(2); |
| 341 |
|
|
| 342 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 343 |
|
$createStruct->alwaysAvailable = false; |
| 344 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 345 |
|
$createStruct->setField( |
| 346 |
|
'maplocation', |
| 347 |
|
array( |
| 348 |
|
'latitude' => 45.894877, |
| 349 |
|
'longitude' => 15.972699, |
| 350 |
|
'address' => 'Here be wild boars', |
| 351 |
|
), |
| 352 |
|
'eng-GB' |
| 353 |
|
); |
| 354 |
|
|
| 355 |
|
$draft = $contentService->createContent($createStruct, array($locationCreateStruct)); |
| 356 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 357 |
|
|
| 358 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 359 |
|
$createStruct->alwaysAvailable = false; |
| 360 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 361 |
|
$createStruct->setField( |
| 362 |
|
'maplocation', |
| 363 |
|
array( |
| 364 |
|
'latitude' => 45.927334, |
| 365 |
|
'longitude' => 15.934847, |
| 366 |
|
'address' => 'A lone tree', |
| 367 |
|
), |
| 368 |
|
'eng-GB' |
| 369 |
|
); |
| 370 |
|
|
| 371 |
|
$draft = $contentService->createContent($createStruct, array($locationCreateStruct)); |
| 372 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 373 |
|
|
| 374 |
|
$this->refreshSearch($repository); |
| 375 |
|
|
| 376 |
|
$query = new LocationQuery( |
| 377 |
|
array( |
| 378 |
|
'filter' => new Criterion\LogicalAnd( |
| 379 |
|
array( |
| 380 |
|
new Criterion\ContentTypeId($contentType->id), |
| 381 |
|
new Criterion\MapLocationDistance( |
| 382 |
|
'maplocation', |
| 383 |
|
Criterion\Operator::LTE, |
| 384 |
|
240, |
| 385 |
|
43.756825, |
| 386 |
|
15.775074 |
| 387 |
|
), |
| 388 |
|
) |
| 389 |
|
), |
| 390 |
|
'offset' => 0, |
| 391 |
|
'limit' => 10, |
| 392 |
|
'sortClauses' => array(), |
| 393 |
|
) |
| 394 |
|
); |
| 395 |
|
|
| 396 |
|
$searchService = $repository->getSearchService(); |
| 397 |
|
$result = $searchService->findLocations($query); |
| 398 |
|
|
| 399 |
|
$this->assertEquals(1, $result->totalCount); |
| 400 |
|
$this->assertEquals( |
| 401 |
|
$wildBoars->contentInfo->mainLocationId, |
| 402 |
|
$result->searchHits[0]->valueObject->id |
| 403 |
|
); |
| 404 |
|
} |
| 405 |
|
|
| 406 |
|
/** |
| 407 |
|
* Test for the findLocations() method. |
|
@@ 412-485 (lines=74) @@
|
| 409 |
|
* @see \eZ\Publish\API\Repository\SearchService::findLocations() |
| 410 |
|
* @group maplocation |
| 411 |
|
*/ |
| 412 |
|
public function testMapLocationDistanceGreaterThanOrEqual() |
| 413 |
|
{ |
| 414 |
|
$contentType = $this->createTestPlaceContentType(); |
| 415 |
|
|
| 416 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 417 |
|
$repository = $this->getRepository(); |
| 418 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 419 |
|
$contentService = $repository->getContentService(); |
| 420 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 421 |
|
$locationCreateStruct = $repository->getLocationService()->newLocationCreateStruct(2); |
| 422 |
|
|
| 423 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 424 |
|
$createStruct->alwaysAvailable = false; |
| 425 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 426 |
|
$createStruct->setField( |
| 427 |
|
'maplocation', |
| 428 |
|
array( |
| 429 |
|
'latitude' => 45.894877, |
| 430 |
|
'longitude' => 15.972699, |
| 431 |
|
'address' => 'Here be wild boars', |
| 432 |
|
), |
| 433 |
|
'eng-GB' |
| 434 |
|
); |
| 435 |
|
|
| 436 |
|
$draft = $contentService->createContent($createStruct, array($locationCreateStruct)); |
| 437 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 438 |
|
|
| 439 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 440 |
|
$createStruct->alwaysAvailable = false; |
| 441 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 442 |
|
$createStruct->setField( |
| 443 |
|
'maplocation', |
| 444 |
|
array( |
| 445 |
|
'latitude' => 45.927334, |
| 446 |
|
'longitude' => 15.934847, |
| 447 |
|
'address' => 'A lone tree', |
| 448 |
|
), |
| 449 |
|
'eng-GB' |
| 450 |
|
); |
| 451 |
|
|
| 452 |
|
$draft = $contentService->createContent($createStruct, array($locationCreateStruct)); |
| 453 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 454 |
|
|
| 455 |
|
$this->refreshSearch($repository); |
| 456 |
|
|
| 457 |
|
$query = new LocationQuery( |
| 458 |
|
array( |
| 459 |
|
'filter' => new Criterion\LogicalAnd( |
| 460 |
|
array( |
| 461 |
|
new Criterion\ContentTypeId($contentType->id), |
| 462 |
|
new Criterion\MapLocationDistance( |
| 463 |
|
'maplocation', |
| 464 |
|
Criterion\Operator::GTE, |
| 465 |
|
240, |
| 466 |
|
43.756825, |
| 467 |
|
15.775074 |
| 468 |
|
), |
| 469 |
|
) |
| 470 |
|
), |
| 471 |
|
'offset' => 0, |
| 472 |
|
'limit' => 10, |
| 473 |
|
'sortClauses' => array(), |
| 474 |
|
) |
| 475 |
|
); |
| 476 |
|
|
| 477 |
|
$searchService = $repository->getSearchService(); |
| 478 |
|
$result = $searchService->findLocations($query); |
| 479 |
|
|
| 480 |
|
$this->assertEquals(1, $result->totalCount); |
| 481 |
|
$this->assertEquals( |
| 482 |
|
$tree->contentInfo->mainLocationId, |
| 483 |
|
$result->searchHits[0]->valueObject->id |
| 484 |
|
); |
| 485 |
|
} |
| 486 |
|
|
| 487 |
|
/** |
| 488 |
|
* Test for the findLocations() method. |