|
@@ 2944-3016 (lines=73) @@
|
| 2941 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 2942 |
|
* @group maplocation |
| 2943 |
|
*/ |
| 2944 |
|
public function testMapLocationDistanceLessThanOrEqual() |
| 2945 |
|
{ |
| 2946 |
|
$contentType = $this->createTestPlaceContentType(); |
| 2947 |
|
|
| 2948 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 2949 |
|
$repository = $this->getRepository(); |
| 2950 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 2951 |
|
$contentService = $repository->getContentService(); |
| 2952 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 2953 |
|
|
| 2954 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2955 |
|
$createStruct->alwaysAvailable = false; |
| 2956 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2957 |
|
$createStruct->setField( |
| 2958 |
|
'maplocation', |
| 2959 |
|
array( |
| 2960 |
|
'latitude' => 45.894877, |
| 2961 |
|
'longitude' => 15.972699, |
| 2962 |
|
'address' => 'Here be wild boars', |
| 2963 |
|
), |
| 2964 |
|
'eng-GB' |
| 2965 |
|
); |
| 2966 |
|
|
| 2967 |
|
$draft = $contentService->createContent($createStruct); |
| 2968 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 2969 |
|
|
| 2970 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2971 |
|
$createStruct->alwaysAvailable = false; |
| 2972 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2973 |
|
$createStruct->setField( |
| 2974 |
|
'maplocation', |
| 2975 |
|
array( |
| 2976 |
|
'latitude' => 45.927334, |
| 2977 |
|
'longitude' => 15.934847, |
| 2978 |
|
'address' => 'A lone tree', |
| 2979 |
|
), |
| 2980 |
|
'eng-GB' |
| 2981 |
|
); |
| 2982 |
|
|
| 2983 |
|
$draft = $contentService->createContent($createStruct); |
| 2984 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 2985 |
|
|
| 2986 |
|
$this->refreshSearch($repository); |
| 2987 |
|
|
| 2988 |
|
$query = new Query( |
| 2989 |
|
array( |
| 2990 |
|
'filter' => new Criterion\LogicalAnd( |
| 2991 |
|
array( |
| 2992 |
|
new Criterion\ContentTypeId($contentType->id), |
| 2993 |
|
new Criterion\MapLocationDistance( |
| 2994 |
|
'maplocation', |
| 2995 |
|
Criterion\Operator::LTE, |
| 2996 |
|
240, |
| 2997 |
|
43.756825, |
| 2998 |
|
15.775074 |
| 2999 |
|
), |
| 3000 |
|
) |
| 3001 |
|
), |
| 3002 |
|
'offset' => 0, |
| 3003 |
|
'limit' => 10, |
| 3004 |
|
'sortClauses' => array(), |
| 3005 |
|
) |
| 3006 |
|
); |
| 3007 |
|
|
| 3008 |
|
$searchService = $repository->getSearchService(); |
| 3009 |
|
$result = $searchService->findContent($query); |
| 3010 |
|
|
| 3011 |
|
$this->assertEquals(1, $result->totalCount); |
| 3012 |
|
$this->assertEquals( |
| 3013 |
|
$wildBoars->id, |
| 3014 |
|
$result->searchHits[0]->valueObject->id |
| 3015 |
|
); |
| 3016 |
|
} |
| 3017 |
|
|
| 3018 |
|
/** |
| 3019 |
|
* Test for the findContent() method. |
|
@@ 3024-3096 (lines=73) @@
|
| 3021 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 3022 |
|
* @group maplocation |
| 3023 |
|
*/ |
| 3024 |
|
public function testMapLocationDistanceGreaterThanOrEqual() |
| 3025 |
|
{ |
| 3026 |
|
$contentType = $this->createTestPlaceContentType(); |
| 3027 |
|
|
| 3028 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 3029 |
|
$repository = $this->getRepository(); |
| 3030 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 3031 |
|
$contentService = $repository->getContentService(); |
| 3032 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 3033 |
|
|
| 3034 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 3035 |
|
$createStruct->alwaysAvailable = false; |
| 3036 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 3037 |
|
$createStruct->setField( |
| 3038 |
|
'maplocation', |
| 3039 |
|
array( |
| 3040 |
|
'latitude' => 45.894877, |
| 3041 |
|
'longitude' => 15.972699, |
| 3042 |
|
'address' => 'Here be wild boars', |
| 3043 |
|
), |
| 3044 |
|
'eng-GB' |
| 3045 |
|
); |
| 3046 |
|
|
| 3047 |
|
$draft = $contentService->createContent($createStruct); |
| 3048 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 3049 |
|
|
| 3050 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 3051 |
|
$createStruct->alwaysAvailable = false; |
| 3052 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 3053 |
|
$createStruct->setField( |
| 3054 |
|
'maplocation', |
| 3055 |
|
array( |
| 3056 |
|
'latitude' => 45.927334, |
| 3057 |
|
'longitude' => 15.934847, |
| 3058 |
|
'address' => 'A lone tree', |
| 3059 |
|
), |
| 3060 |
|
'eng-GB' |
| 3061 |
|
); |
| 3062 |
|
|
| 3063 |
|
$draft = $contentService->createContent($createStruct); |
| 3064 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 3065 |
|
|
| 3066 |
|
$this->refreshSearch($repository); |
| 3067 |
|
|
| 3068 |
|
$query = new Query( |
| 3069 |
|
array( |
| 3070 |
|
'filter' => new Criterion\LogicalAnd( |
| 3071 |
|
array( |
| 3072 |
|
new Criterion\ContentTypeId($contentType->id), |
| 3073 |
|
new Criterion\MapLocationDistance( |
| 3074 |
|
'maplocation', |
| 3075 |
|
Criterion\Operator::GTE, |
| 3076 |
|
240, |
| 3077 |
|
43.756825, |
| 3078 |
|
15.775074 |
| 3079 |
|
), |
| 3080 |
|
) |
| 3081 |
|
), |
| 3082 |
|
'offset' => 0, |
| 3083 |
|
'limit' => 10, |
| 3084 |
|
'sortClauses' => array(), |
| 3085 |
|
) |
| 3086 |
|
); |
| 3087 |
|
|
| 3088 |
|
$searchService = $repository->getSearchService(); |
| 3089 |
|
$result = $searchService->findContent($query); |
| 3090 |
|
|
| 3091 |
|
$this->assertEquals(1, $result->totalCount); |
| 3092 |
|
$this->assertEquals( |
| 3093 |
|
$tree->id, |
| 3094 |
|
$result->searchHits[0]->valueObject->id |
| 3095 |
|
); |
| 3096 |
|
} |
| 3097 |
|
|
| 3098 |
|
/** |
| 3099 |
|
* Test for the findContent() method. |