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