|
@@ 2877-2949 (lines=73) @@
|
| 2874 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 2875 |
|
* @group maplocation |
| 2876 |
|
*/ |
| 2877 |
|
public function testMapLocationDistanceLessThanOrEqual() |
| 2878 |
|
{ |
| 2879 |
|
$contentType = $this->createTestPlaceContentType(); |
| 2880 |
|
|
| 2881 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 2882 |
|
$repository = $this->getRepository(); |
| 2883 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 2884 |
|
$contentService = $repository->getContentService(); |
| 2885 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 2886 |
|
|
| 2887 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2888 |
|
$createStruct->alwaysAvailable = false; |
| 2889 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2890 |
|
$createStruct->setField( |
| 2891 |
|
'maplocation', |
| 2892 |
|
array( |
| 2893 |
|
'latitude' => 45.894877, |
| 2894 |
|
'longitude' => 15.972699, |
| 2895 |
|
'address' => 'Here be wild boars', |
| 2896 |
|
), |
| 2897 |
|
'eng-GB' |
| 2898 |
|
); |
| 2899 |
|
|
| 2900 |
|
$draft = $contentService->createContent($createStruct); |
| 2901 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 2902 |
|
|
| 2903 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2904 |
|
$createStruct->alwaysAvailable = false; |
| 2905 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2906 |
|
$createStruct->setField( |
| 2907 |
|
'maplocation', |
| 2908 |
|
array( |
| 2909 |
|
'latitude' => 45.927334, |
| 2910 |
|
'longitude' => 15.934847, |
| 2911 |
|
'address' => 'A lone tree', |
| 2912 |
|
), |
| 2913 |
|
'eng-GB' |
| 2914 |
|
); |
| 2915 |
|
|
| 2916 |
|
$draft = $contentService->createContent($createStruct); |
| 2917 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 2918 |
|
|
| 2919 |
|
$this->refreshSearch($repository); |
| 2920 |
|
|
| 2921 |
|
$query = new Query( |
| 2922 |
|
array( |
| 2923 |
|
'filter' => new Criterion\LogicalAnd( |
| 2924 |
|
array( |
| 2925 |
|
new Criterion\ContentTypeId($contentType->id), |
| 2926 |
|
new Criterion\MapLocationDistance( |
| 2927 |
|
'maplocation', |
| 2928 |
|
Criterion\Operator::LTE, |
| 2929 |
|
240, |
| 2930 |
|
43.756825, |
| 2931 |
|
15.775074 |
| 2932 |
|
), |
| 2933 |
|
) |
| 2934 |
|
), |
| 2935 |
|
'offset' => 0, |
| 2936 |
|
'limit' => 10, |
| 2937 |
|
'sortClauses' => array(), |
| 2938 |
|
) |
| 2939 |
|
); |
| 2940 |
|
|
| 2941 |
|
$searchService = $repository->getSearchService(); |
| 2942 |
|
$result = $searchService->findContent($query); |
| 2943 |
|
|
| 2944 |
|
$this->assertEquals(1, $result->totalCount); |
| 2945 |
|
$this->assertEquals( |
| 2946 |
|
$wildBoars->id, |
| 2947 |
|
$result->searchHits[0]->valueObject->id |
| 2948 |
|
); |
| 2949 |
|
} |
| 2950 |
|
|
| 2951 |
|
/** |
| 2952 |
|
* Test for the findContent() method. |
|
@@ 2957-3029 (lines=73) @@
|
| 2954 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 2955 |
|
* @group maplocation |
| 2956 |
|
*/ |
| 2957 |
|
public function testMapLocationDistanceGreaterThanOrEqual() |
| 2958 |
|
{ |
| 2959 |
|
$contentType = $this->createTestPlaceContentType(); |
| 2960 |
|
|
| 2961 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 2962 |
|
$repository = $this->getRepository(); |
| 2963 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 2964 |
|
$contentService = $repository->getContentService(); |
| 2965 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 2966 |
|
|
| 2967 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2968 |
|
$createStruct->alwaysAvailable = false; |
| 2969 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2970 |
|
$createStruct->setField( |
| 2971 |
|
'maplocation', |
| 2972 |
|
array( |
| 2973 |
|
'latitude' => 45.894877, |
| 2974 |
|
'longitude' => 15.972699, |
| 2975 |
|
'address' => 'Here be wild boars', |
| 2976 |
|
), |
| 2977 |
|
'eng-GB' |
| 2978 |
|
); |
| 2979 |
|
|
| 2980 |
|
$draft = $contentService->createContent($createStruct); |
| 2981 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 2982 |
|
|
| 2983 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2984 |
|
$createStruct->alwaysAvailable = false; |
| 2985 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2986 |
|
$createStruct->setField( |
| 2987 |
|
'maplocation', |
| 2988 |
|
array( |
| 2989 |
|
'latitude' => 45.927334, |
| 2990 |
|
'longitude' => 15.934847, |
| 2991 |
|
'address' => 'A lone tree', |
| 2992 |
|
), |
| 2993 |
|
'eng-GB' |
| 2994 |
|
); |
| 2995 |
|
|
| 2996 |
|
$draft = $contentService->createContent($createStruct); |
| 2997 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 2998 |
|
|
| 2999 |
|
$this->refreshSearch($repository); |
| 3000 |
|
|
| 3001 |
|
$query = new Query( |
| 3002 |
|
array( |
| 3003 |
|
'filter' => new Criterion\LogicalAnd( |
| 3004 |
|
array( |
| 3005 |
|
new Criterion\ContentTypeId($contentType->id), |
| 3006 |
|
new Criterion\MapLocationDistance( |
| 3007 |
|
'maplocation', |
| 3008 |
|
Criterion\Operator::GTE, |
| 3009 |
|
240, |
| 3010 |
|
43.756825, |
| 3011 |
|
15.775074 |
| 3012 |
|
), |
| 3013 |
|
) |
| 3014 |
|
), |
| 3015 |
|
'offset' => 0, |
| 3016 |
|
'limit' => 10, |
| 3017 |
|
'sortClauses' => array(), |
| 3018 |
|
) |
| 3019 |
|
); |
| 3020 |
|
|
| 3021 |
|
$searchService = $repository->getSearchService(); |
| 3022 |
|
$result = $searchService->findContent($query); |
| 3023 |
|
|
| 3024 |
|
$this->assertEquals(1, $result->totalCount); |
| 3025 |
|
$this->assertEquals( |
| 3026 |
|
$tree->id, |
| 3027 |
|
$result->searchHits[0]->valueObject->id |
| 3028 |
|
); |
| 3029 |
|
} |
| 3030 |
|
|
| 3031 |
|
/** |
| 3032 |
|
* Test for the findContent() method. |