|
@@ 2793-2865 (lines=73) @@
|
| 2790 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 2791 |
|
* @group maplocation |
| 2792 |
|
*/ |
| 2793 |
|
public function testMapLocationDistanceLessThanOrEqual() |
| 2794 |
|
{ |
| 2795 |
|
$contentType = $this->createTestPlaceContentType(); |
| 2796 |
|
|
| 2797 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 2798 |
|
$repository = $this->getRepository(); |
| 2799 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 2800 |
|
$contentService = $repository->getContentService(); |
| 2801 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 2802 |
|
|
| 2803 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2804 |
|
$createStruct->alwaysAvailable = false; |
| 2805 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2806 |
|
$createStruct->setField( |
| 2807 |
|
'maplocation', |
| 2808 |
|
[ |
| 2809 |
|
'latitude' => 45.894877, |
| 2810 |
|
'longitude' => 15.972699, |
| 2811 |
|
'address' => 'Here be wild boars', |
| 2812 |
|
], |
| 2813 |
|
'eng-GB' |
| 2814 |
|
); |
| 2815 |
|
|
| 2816 |
|
$draft = $contentService->createContent($createStruct); |
| 2817 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 2818 |
|
|
| 2819 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2820 |
|
$createStruct->alwaysAvailable = false; |
| 2821 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2822 |
|
$createStruct->setField( |
| 2823 |
|
'maplocation', |
| 2824 |
|
[ |
| 2825 |
|
'latitude' => 45.927334, |
| 2826 |
|
'longitude' => 15.934847, |
| 2827 |
|
'address' => 'A lone tree', |
| 2828 |
|
], |
| 2829 |
|
'eng-GB' |
| 2830 |
|
); |
| 2831 |
|
|
| 2832 |
|
$draft = $contentService->createContent($createStruct); |
| 2833 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 2834 |
|
|
| 2835 |
|
$this->refreshSearch($repository); |
| 2836 |
|
|
| 2837 |
|
$query = new Query( |
| 2838 |
|
[ |
| 2839 |
|
'filter' => new Criterion\LogicalAnd( |
| 2840 |
|
[ |
| 2841 |
|
new Criterion\ContentTypeId($contentType->id), |
| 2842 |
|
new Criterion\MapLocationDistance( |
| 2843 |
|
'maplocation', |
| 2844 |
|
Criterion\Operator::LTE, |
| 2845 |
|
240, |
| 2846 |
|
43.756825, |
| 2847 |
|
15.775074 |
| 2848 |
|
), |
| 2849 |
|
] |
| 2850 |
|
), |
| 2851 |
|
'offset' => 0, |
| 2852 |
|
'limit' => 10, |
| 2853 |
|
'sortClauses' => [], |
| 2854 |
|
] |
| 2855 |
|
); |
| 2856 |
|
|
| 2857 |
|
$searchService = $repository->getSearchService(); |
| 2858 |
|
$result = $searchService->findContent($query); |
| 2859 |
|
|
| 2860 |
|
$this->assertEquals(1, $result->totalCount); |
| 2861 |
|
$this->assertEquals( |
| 2862 |
|
$wildBoars->id, |
| 2863 |
|
$result->searchHits[0]->valueObject->id |
| 2864 |
|
); |
| 2865 |
|
} |
| 2866 |
|
|
| 2867 |
|
/** |
| 2868 |
|
* Test for the findContent() method. |
|
@@ 2873-2945 (lines=73) @@
|
| 2870 |
|
* @see \eZ\Publish\API\Repository\SearchService::findContent() |
| 2871 |
|
* @group maplocation |
| 2872 |
|
*/ |
| 2873 |
|
public function testMapLocationDistanceGreaterThanOrEqual() |
| 2874 |
|
{ |
| 2875 |
|
$contentType = $this->createTestPlaceContentType(); |
| 2876 |
|
|
| 2877 |
|
// Create a draft to account for behaviour with ContentType in different states |
| 2878 |
|
$repository = $this->getRepository(); |
| 2879 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 2880 |
|
$contentService = $repository->getContentService(); |
| 2881 |
|
$contentTypeService->createContentTypeDraft($contentType); |
| 2882 |
|
|
| 2883 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2884 |
|
$createStruct->alwaysAvailable = false; |
| 2885 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2886 |
|
$createStruct->setField( |
| 2887 |
|
'maplocation', |
| 2888 |
|
[ |
| 2889 |
|
'latitude' => 45.894877, |
| 2890 |
|
'longitude' => 15.972699, |
| 2891 |
|
'address' => 'Here be wild boars', |
| 2892 |
|
], |
| 2893 |
|
'eng-GB' |
| 2894 |
|
); |
| 2895 |
|
|
| 2896 |
|
$draft = $contentService->createContent($createStruct); |
| 2897 |
|
$wildBoars = $contentService->publishVersion($draft->getVersionInfo()); |
| 2898 |
|
|
| 2899 |
|
$createStruct = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2900 |
|
$createStruct->alwaysAvailable = false; |
| 2901 |
|
$createStruct->mainLanguageCode = 'eng-GB'; |
| 2902 |
|
$createStruct->setField( |
| 2903 |
|
'maplocation', |
| 2904 |
|
[ |
| 2905 |
|
'latitude' => 45.927334, |
| 2906 |
|
'longitude' => 15.934847, |
| 2907 |
|
'address' => 'A lone tree', |
| 2908 |
|
], |
| 2909 |
|
'eng-GB' |
| 2910 |
|
); |
| 2911 |
|
|
| 2912 |
|
$draft = $contentService->createContent($createStruct); |
| 2913 |
|
$tree = $contentService->publishVersion($draft->getVersionInfo()); |
| 2914 |
|
|
| 2915 |
|
$this->refreshSearch($repository); |
| 2916 |
|
|
| 2917 |
|
$query = new Query( |
| 2918 |
|
[ |
| 2919 |
|
'filter' => new Criterion\LogicalAnd( |
| 2920 |
|
[ |
| 2921 |
|
new Criterion\ContentTypeId($contentType->id), |
| 2922 |
|
new Criterion\MapLocationDistance( |
| 2923 |
|
'maplocation', |
| 2924 |
|
Criterion\Operator::GTE, |
| 2925 |
|
240, |
| 2926 |
|
43.756825, |
| 2927 |
|
15.775074 |
| 2928 |
|
), |
| 2929 |
|
] |
| 2930 |
|
), |
| 2931 |
|
'offset' => 0, |
| 2932 |
|
'limit' => 10, |
| 2933 |
|
'sortClauses' => [], |
| 2934 |
|
] |
| 2935 |
|
); |
| 2936 |
|
|
| 2937 |
|
$searchService = $repository->getSearchService(); |
| 2938 |
|
$result = $searchService->findContent($query); |
| 2939 |
|
|
| 2940 |
|
$this->assertEquals(1, $result->totalCount); |
| 2941 |
|
$this->assertEquals( |
| 2942 |
|
$tree->id, |
| 2943 |
|
$result->searchHits[0]->valueObject->id |
| 2944 |
|
); |
| 2945 |
|
} |
| 2946 |
|
|
| 2947 |
|
/** |
| 2948 |
|
* Test for the findContent() method. |