|
@@ 3010-3082 (lines=73) @@
|
| 3007 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 3008 |
|
* @group maplocation |
| 3009 |
|
*/ |
| 3010 |
|
public function testMapLocationDistanceLessThanOrEqual() |
| 3011 |
|
{ |
| 3012 |
|
$contentType = $this->createTestPlaceContentType(); |
| 3013 |
|
|
| 3014 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 3015 |
|
$repository = $this->getRepository(); |
| 3016 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 3017 |
|
$contentService = $repository->getContentService(); |
| 3018 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 3019 |
|
|
| 3020 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 3021 |
|
$createStruct->alwaysAvailable = false; |
| 3022 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 3023 |
|
$createStruct->setField( |
| 3024 |
|
'maplocation', |
| 3025 |
|
array( |
| 3026 |
|
'latitude' => 45.894877, |
| 3027 |
|
'longitude' => 15.972699, |
| 3028 |
|
'address' => 'Here be wild boars', |
| 3029 |
|
), |
| 3030 |
|
'eng-GB' |
| 3031 |
|
); |
| 3032 |
|
|
| 3033 |
|
$draft = $contentService->createContent($createStruct); |
| 3034 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 3035 |
|
|
| 3036 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 3037 |
|
$createStruct->alwaysAvailable = false; |
| 3038 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 3039 |
|
$createStruct->setField( |
| 3040 |
|
'maplocation', |
| 3041 |
|
array( |
| 3042 |
|
'latitude' => 45.927334, |
| 3043 |
|
'longitude' => 15.934847, |
| 3044 |
|
'address' => 'A lone tree', |
| 3045 |
|
), |
| 3046 |
|
'eng-GB' |
| 3047 |
|
); |
| 3048 |
|
|
| 3049 |
|
$draft = $contentService->createContent($createStruct); |
| 3050 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 3051 |
|
|
| 3052 |
|
$this->refreshSearch($repository); |
| 3053 |
|
|
| 3054 |
|
$query = new Query( |
| 3055 |
|
array( |
| 3056 |
|
'filter' => new Criterion\LogicalAnd( |
| 3057 |
|
array( |
| 3058 |
|
new Criterion\ContentTypeId($contentType->id), |
| 3059 |
|
new Criterion\MapLocationDistance( |
| 3060 |
|
'maplocation', |
| 3061 |
|
Criterion\Operator::LTE, |
| 3062 |
|
240, |
| 3063 |
|
43.756825, |
| 3064 |
|
15.775074 |
| 3065 |
|
), |
| 3066 |
|
) |
| 3067 |
|
), |
| 3068 |
|
'offset' => 0, |
| 3069 |
|
'limit' => 10, |
| 3070 |
|
'sortClauses' => array(), |
| 3071 |
|
) |
| 3072 |
|
); |
| 3073 |
|
|
| 3074 |
|
$searchService = $repository->getSearchService(); |
| 3075 |
|
$result = $searchService->findContent($query); |
| 3076 |
|
|
| 3077 |
|
$this->assertEquals(1, $result->totalCount); |
| 3078 |
|
$this->assertEquals( |
| 3079 |
|
$wildBoars->id, |
| 3080 |
|
$result->searchHits[0]->valueObject->id |
| 3081 |
|
); |
| 3082 |
|
} |
| 3083 |
|
|
| 3084 |
|
/** |
| 3085 |
|
* Test for the findContent() method. |
|
@@ 3090-3162 (lines=73) @@
|
| 3087 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 3088 |
|
* @group maplocation |
| 3089 |
|
*/ |
| 3090 |
|
public function testMapLocationDistanceGreaterThanOrEqual() |
| 3091 |
|
{ |
| 3092 |
|
$contentType = $this->createTestPlaceContentType(); |
| 3093 |
|
|
| 3094 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 3095 |
|
$repository = $this->getRepository(); |
| 3096 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 3097 |
|
$contentService = $repository->getContentService(); |
| 3098 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 3099 |
|
|
| 3100 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 3101 |
|
$createStruct->alwaysAvailable = false; |
| 3102 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 3103 |
|
$createStruct->setField( |
| 3104 |
|
'maplocation', |
| 3105 |
|
array( |
| 3106 |
|
'latitude' => 45.894877, |
| 3107 |
|
'longitude' => 15.972699, |
| 3108 |
|
'address' => 'Here be wild boars', |
| 3109 |
|
), |
| 3110 |
|
'eng-GB' |
| 3111 |
|
); |
| 3112 |
|
|
| 3113 |
|
$draft = $contentService->createContent($createStruct); |
| 3114 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 3115 |
|
|
| 3116 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 3117 |
|
$createStruct->alwaysAvailable = false; |
| 3118 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 3119 |
|
$createStruct->setField( |
| 3120 |
|
'maplocation', |
| 3121 |
|
array( |
| 3122 |
|
'latitude' => 45.927334, |
| 3123 |
|
'longitude' => 15.934847, |
| 3124 |
|
'address' => 'A lone tree', |
| 3125 |
|
), |
| 3126 |
|
'eng-GB' |
| 3127 |
|
); |
| 3128 |
|
|
| 3129 |
|
$draft = $contentService->createContent($createStruct); |
| 3130 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 3131 |
|
|
| 3132 |
|
$this->refreshSearch($repository); |
| 3133 |
|
|
| 3134 |
|
$query = new Query( |
| 3135 |
|
array( |
| 3136 |
|
'filter' => new Criterion\LogicalAnd( |
| 3137 |
|
array( |
| 3138 |
|
new Criterion\ContentTypeId($contentType->id), |
| 3139 |
|
new Criterion\MapLocationDistance( |
| 3140 |
|
'maplocation', |
| 3141 |
|
Criterion\Operator::GTE, |
| 3142 |
|
240, |
| 3143 |
|
43.756825, |
| 3144 |
|
15.775074 |
| 3145 |
|
), |
| 3146 |
|
) |
| 3147 |
|
), |
| 3148 |
|
'offset' => 0, |
| 3149 |
|
'limit' => 10, |
| 3150 |
|
'sortClauses' => array(), |
| 3151 |
|
) |
| 3152 |
|
); |
| 3153 |
|
|
| 3154 |
|
$searchService = $repository->getSearchService(); |
| 3155 |
|
$result = $searchService->findContent($query); |
| 3156 |
|
|
| 3157 |
|
$this->assertEquals(1, $result->totalCount); |
| 3158 |
|
$this->assertEquals( |
| 3159 |
|
$tree->id, |
| 3160 |
|
$result->searchHits[0]->valueObject->id |
| 3161 |
|
); |
| 3162 |
|
} |
| 3163 |
|
|
| 3164 |
|
/** |
| 3165 |
|
* Test for the findContent() method. |