diff --git a/_config/config.yml b/_config/config.yml index 87f068a..0e37b20 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -10,10 +10,13 @@ Dynamic\Locator\Location: Dynamic\Locator\Locator: infoWindowTemplate: 'dynamic/silverstripe-locator: client/infowindow-description.html' listTemplate: 'dynamic/silverstripe-locator: client/location-list-description.html' - limit: 50 show_radius: true + +Dynamic\Locator\Control\APIController: radius_var: 'Radius' category_var: 'CategoryID' + limit_var: 'Limit' + limit: 50 --- Name: modules-locator diff --git a/_config/routes.yml b/_config/routes.yml new file mode 100644 index 0000000..93aacde --- /dev/null +++ b/_config/routes.yml @@ -0,0 +1,7 @@ +--- +Name: locator-routes +--- +SilverStripe\Control\Director: + rules: + LocatorAPI: + Controller: 'Dynamic\Locator\Control\APIController' diff --git a/src/admin/LocationAdmin.php b/src/Admin/LocationAdmin.php similarity index 100% rename from src/admin/LocationAdmin.php rename to src/Admin/LocationAdmin.php diff --git a/src/Control/APIController.php b/src/Control/APIController.php new file mode 100644 index 0000000..89c1e8a --- /dev/null +++ b/src/Control/APIController.php @@ -0,0 +1,301 @@ + 0, + 'Lng' => 0, + ]; + + /** + * @var array + */ + private static $base_filter_any = []; + + /** + * @var \SilverStripe\ORM\DataList|\SilverStripe\ORM\ArrayList + */ + private $locations; + + /** + * @return \SilverStripe\ORM\FieldType\DBHTMLText + */ + public function index() + { + return $this->xml(); + } + + /** + * Renders locations in xml format + * + * @return \SilverStripe\ORM\FieldType\DBHTMLText + */ + public function xml() + { + $this->getResponse()->addHeader("Content-Type", "application/xml"); + $data = new ArrayData(array( + "Locations" => $this->getLocations(), + "AddressCoords" => $this->getAddressSearchCoords(), + )); + + return $data->renderWith('Dynamic/Locator/Data/XML'); + } + + /** + * Renders locations in json format + * + * @return \SilverStripe\ORM\FieldType\DBHTMLText + */ + public function json() + { + $this->getResponse()->addHeader("Content-Type", "application/json"); + $data = new ArrayData(array( + "Locations" => $this->getLocations(), + "AddressCoords" => $this->getAddressSearchCoords(), + )); + + return $data->renderWith('Dynamic/Locator/Data/JSON'); + } + + /** + * @param HTTPRequest|null $request + * @return ArrayList|DataList + */ + public function getLocations(HTTPRequest $request = null) + { + if ($request === null) { + $request = $this->getRequest(); + } + + if (!$this->locations) { + $this->setLocations($request); + } + + return $this->locations; + } + + /** + * @param HTTPRequest|null $request + * + * @return $this + */ + public function setLocations(HTTPRequest $request = null) + { + + if ($request === null) { + $request = $this->getRequest(); + } + + $locations = $this->getLocationList($request); + + if ($locations->canSortBy('Distance')) { + $locations = $locations->sort('Distance'); + } + + // filter out locations farther than the radius + $radiusVar = $this->config()->get('radius_var'); + if ($radius = (int)$request->getVar($radiusVar)) { + $locations = $locations->filterByCallback(function ($location) use (&$radius) { + return $location->Distance <= $radius; + }); + } + + $this->extend('updateListType', $locations); + + $limit = $this->getLimit($request); + if ($limit > 0) { + $locations = $locations->limit($limit); + } + + $this->locations = $locations; + + return $this; + } + + /** + * @param HTTPRequest $request + * @return \SilverStripe\ORM\ArrayList + */ + public function getLocationList(HTTPRequest $request) + { + if ($request === null) { + $request = $this->getRequest(); + } + + $filter = $this->getFilter($request); + $filterAny = $this->getFilterAny($request); + $exclude = $this->getExclude($request); + + $locationClass = $this->config()->get('location_class'); + + $locations = $locationClass::get(); + + if (!empty($filter)) { + $locations = $locations->filter($filter); + } + + if (!empty($filterAny)) { + $locations = $locations->filterAny($filterAny); + } + + if (!empty($exclude)) { + $locations = $locations->exclude($exclude); + } + + $locations = DataToArrayListHelper::to_array_list($locations); + $this->extend('updateLocationList', $locations); + return $locations; + } + + /** + * @param \SilverStripe\Control\HTTPRequest $request + * @return array + */ + public function getFilter(HTTPRequest $request) + { + $filter = $this->config()->get('base_filter'); + + // filter by category + $categoryVar = $this->config()->get('category_var'); + if ($request->getVar($categoryVar)) { + $filter['Categories.ID'] = $request->getVar($categoryVar); + } + + $this->extend('updateFilter', $filter, $request); + return $filter; + } + + /** + * @param \SilverStripe\Control\HTTPRequest $request + * @return array + */ + public function getFilterAny(HTTPRequest $request) + { + $filterAny = $this->config()->get('base_filter_any'); + $this->extend('updateFilterAny', $filterAny, $request); + return $filterAny; + } + + /** + * @param \SilverStripe\Control\HTTPRequest $request + * @return array + */ + public function getExclude(HTTPRequest $request) + { + $exclude = $this->config()->get('base_exclude'); + $this->extend('updateExclude', $exclude, $request); + return $exclude; + } + + /** + * @param \SilverStripe\Control\HTTPRequest $request + * @return int + */ + public function getLimit(HTTPRequest $request) + { + $limitVar = $this->config()->get('limit_var'); + $requestedLimit = $request->getVar($limitVar); + $maxLimit = $this->config()->get('limit'); + $limit = $maxLimit; + + if ($requestedLimit && $requestedLimit < $maxLimit) { + $limit = $requestedLimit; + } + + $this->extend('updateLimit', $limit, $request); + return $limit; + } + + /** + * @return ArrayData|boolean + */ + public function getAddressSearchCoords(HTTPRequest $request = null) + { + if ($request === null) { + $request = $this->getRequest(); + } + + $addressVar = Config::inst()->get(DistanceDataExtension::class, 'address_var'); + if (!$request->getVar($addressVar)) { + return false; + } + if (class_exists(GoogleGeocoder::class)) { + $geocoder = new GoogleGeocoder($request->getVar($addressVar)); + $response = $geocoder->getResult(); + $lat = $response->getLatitude(); + $lng = $response->getLongitude(); + + return new ArrayData([ + "Lat" => $lat, + "Lng" => $lng, + ]); + } + } + + /** + * @param string|null $action + * @return string + */ + public function Link($action = null) + { + return Controller::join_links(static::getRoute(), $action); + } + + /** + * Gets the current route of the controller. + * + * @return int|string + */ + public static function getRoute() + { + $rules = Director::config()->get('rules'); + foreach ($rules as $route => $class) { + if (is_array($class)) { + if ($class['Controller'] === static::class) { + return $route; + } + } + if ($class === static::class) { + return $route; + } + } + return ''; + } +} diff --git a/src/form/LocatorForm.php b/src/Form/LocatorForm.php similarity index 100% rename from src/form/LocatorForm.php rename to src/Form/LocatorForm.php diff --git a/src/objects/Location.php b/src/Model/Location.php similarity index 100% rename from src/objects/Location.php rename to src/Model/Location.php diff --git a/src/objects/LocationCategory.php b/src/Model/LocationCategory.php similarity index 100% rename from src/objects/LocationCategory.php rename to src/Model/LocationCategory.php diff --git a/src/pages/Locator.php b/src/Page/Locator.php similarity index 85% rename from src/pages/Locator.php rename to src/Page/Locator.php index 173b615..60e705f 100644 --- a/src/pages/Locator.php +++ b/src/Page/Locator.php @@ -3,16 +3,17 @@ namespace Dynamic\Locator; use Dynamic\SilverStripeGeocoder\AddressDataExtension; +use SilverStripe\Core\Config\Config; use SilverStripe\Core\Manifest\ModuleResourceLoader; use SilverStripe\Forms\FieldList; +use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldAddExistingAutocompleter; +use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; use SilverStripe\Forms\HeaderField; +use SilverStripe\Forms\NumericField; use SilverStripe\Forms\OptionsetField; -use SilverStripe\Forms\GridField\GridField; -use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; -use SilverStripe\ORM\DataList; use SilverStripe\ORM\ArrayList; -use SilverStripe\Core\Config\Config; +use SilverStripe\ORM\DataList; use SilverStripe\View\ArrayData; use Symbiote\GridFieldExtensions\GridFieldAddExistingSearchButton; @@ -22,6 +23,9 @@ * @property bool $AutoGeocode * @property bool $ModalWindow * @property string $Unit + * @property float $DefaultLat + * @property float $DefaultLng + * * @method Categories|ManyManyList $Categories */ class Locator extends \Page @@ -45,6 +49,8 @@ class Locator extends \Page * @var array */ private static $db = array( + 'DefaultLat' => 'Decimal(10,7)', + 'DefaultLng' => 'Decimal(10,7)', 'Unit' => 'Enum("m,km","m")', ); @@ -60,11 +66,6 @@ class Locator extends \Page */ private static $table_name = 'Locator'; - /** - * @var string - */ - private static $location_class = Location::class; - /** * @return FieldList */ @@ -75,6 +76,12 @@ public function getCMSFields() $fields->addFieldsToTab('Root.Settings', array( HeaderField::create('DisplayOptions', 'Display Options', 3), OptionsetField::create('Unit', 'Unit of measure', array('m' => 'Miles', 'km' => 'Kilometers')), + NumericField::create('DefaultLat') + ->setTitle('Default Latitude') + ->setScale(7), + NumericField::create('DefaultLng') + ->setTitle('Default Longitude') + ->setScale(7), )); // Filter categories @@ -95,37 +102,6 @@ public function getCMSFields() return parent::getCMSFields(); } - /** - * @param array $filter - * @param array $filterAny - * @param array $exclude - * @param null|callable $callback - * - * @return DataList|ArrayList - */ - public static function get_locations( - $filter = [], - $filterAny = [], - $exclude = [], - $callback = null - ) { - $locationClass = Config::inst()->get(Locator::class, 'location_class'); - $locations = $locationClass::get()->filter($filter)->exclude($exclude); - - if (!empty($filterAny)) { - $locations = $locations->filterAny($filterAny); - } - if (!empty($exclude)) { - $locations = $locations->exclude($exclude); - } - - if ($callback !== null && is_callable($callback)) { - $locations->filterByCallback($callback); - } - - return $locations; - } - /** * @return DataList */ @@ -177,6 +153,9 @@ public function getRadii() return $radii; } + /** + * @return \SilverStripe\ORM\ArrayList + */ public function getRadiiArrayList() { $list = []; @@ -256,7 +235,11 @@ public function getMapStyle() return AddressDataExtension::getMapStyleJSON(); } - public function getMapStyleJSONPath() { + /** + * @return bool|string + */ + public function getMapStyleJSONPath() + { return AddressDataExtension::getMapStyleJSONPath(); } diff --git a/src/pages/LocatorController.php b/src/Page/LocatorController.php similarity index 53% rename from src/pages/LocatorController.php rename to src/Page/LocatorController.php index 8a1cd2c..cee942b 100644 --- a/src/pages/LocatorController.php +++ b/src/Page/LocatorController.php @@ -2,6 +2,7 @@ namespace Dynamic\Locator; +use Dynamic\Locator\Control\APIController; use Dynamic\SilverStripeGeocoder\DistanceDataExtension; use Dynamic\SilverStripeGeocoder\GoogleGeocoder; use muskie9\DataToArrayList\ORM\DataToArrayListHelper; @@ -15,34 +16,12 @@ /** * Class LocatorController + * @package Dynamic\Locator + * + * @mixin \Dynamic\Locator\Locator */ class LocatorController extends \PageController { - /** - * @var array - */ - private static $allowed_actions = array( - 'xml', - 'json', - ); - - /** - * @var array - */ - private static $base_filter = []; - - /** - * @var array - */ - private static $base_exclude = [ - 'Lat' => 0, - 'Lng' => 0, - ]; - - /** - * @var array - */ - private static $base_filter_any = []; /** * @var bool @@ -70,11 +49,6 @@ class LocatorController extends \PageController */ private static $query_trigger = 'action_doFilterLocations'; - /** - * @var DataList|ArrayList - */ - protected $locations; - /** * Set Requirements based on input from CMS */ @@ -89,16 +63,17 @@ public function init() $request = Controller::curr()->getRequest(); if ($this->getTrigger($request)) { - $locations = $this->getLocations(); + $apiController = APIController::create(); + $locations = $apiController->getLocations($this->getRequest()); if ($locations) { $featuredInList = ($locations->filter('Featured', true)->count() > 0); - $defaultCoords = $this->getAddressSearchCoords() ? - $this->getAddressSearchCoords() : + $defaultCoords = $apiController->getAddressSearchCoords($this->getRequest()) ? + $apiController->getAddressSearchCoords($this->getRequest()) : new ArrayData([ - "Lat" => 0, - "Lng" => 0, + "Lat" => $this->DefaultLat, + "Lng" => $this->DefaultLat, ]); $featured = $featuredInList @@ -106,7 +81,7 @@ public function init() : 'featuredLocations: false'; // map config based on user input in Settings tab - $limit = Config::inst()->get(LocatorController::class, 'limit'); + $limit = Config::inst()->get(APIController::class, 'limit'); if ($limit < 1) { $limit = -1; } @@ -124,7 +99,7 @@ public function init() if (count($vars)) { $url .= '?' . http_build_query($vars); } - $link = Controller::join_links($this->Link(), 'xml.xml', $url); + $link = Controller::join_links(APIController::create()->Link(), 'xml.xml', $url); // containers $map_id = Config::inst()->get(LocatorController::class, 'map_container'); @@ -139,7 +114,7 @@ public function init() $markerImage = ''; if ($imagePath = $this->getMarkerIcon()) { - $markerImage = "markerImg: '{$imagePath},'"; + $markerImage = "markerImg: '{$imagePath}',"; } // init map @@ -150,7 +125,7 @@ public function init() dataLocation: '{$link}', listTemplatePath: '{$listTemplatePath}', infowindowTemplatePath: '{$infowindowTemplatePath}', - {$markerImage}, + {$markerImage} originMarker: true, {$featured}, slideMap: false, @@ -184,7 +159,7 @@ public function init() public function index(HTTPRequest $request) { if ($this->getTrigger($request)) { - $locations = $this->getLocations(); + $locations = APIController::create()->getLocations($this->getRequest()); } else { $locations = ArrayList::create(); } @@ -194,116 +169,6 @@ public function index(HTTPRequest $request) )); } - /** - * Renders locations in xml format - * - * @return \SilverStripe\ORM\FieldType\DBHTMLText - */ - public function xml() - { - $this->getResponse()->addHeader("Content-Type", "application/xml"); - $data = new ArrayData(array( - "Locations" => $this->getLocations(), - "AddressCoords" => $this->getAddressSearchCoords(), - )); - - return $data->renderWith('Dynamic/Locator/Data/XML'); - } - - /** - * Renders locations in json format - * - * @return \SilverStripe\ORM\FieldType\DBHTMLText - */ - public function json() - { - $this->getResponse()->addHeader("Content-Type", "application/json"); - $data = new ArrayData(array( - "Locations" => $this->getLocations(), - "AddressCoords" => $this->getAddressSearchCoords(), - )); - - return $data->renderWith('Dynamic/Locator/Data/JSON'); - } - - /** - * @return ArrayList|DataList - */ - public function getLocations() - { - if (!$this->locations) { - $this->setLocations($this->request); - } - - return $this->locations; - } - - /** - * @param HTTPRequest|null $request - * - * @return $this - */ - public function setLocations(HTTPRequest $request = null) - { - - if ($request === null) { - $request = $this->request; - } - $filter = $this->config()->get('base_filter'); - - $categoryVar = Config::inst()->get(Locator::class, 'category_var'); - if ($request->getVar($categoryVar)) { - $filter['Categories.ID'] = $request->getVar($categoryVar); - } else { - if ($this->getPageCategories()->exists()) { - foreach ($this->getPageCategories() as $category) { - $filter['Categories.ID'][] = $category->ID; - } - } - } - - $this->extend('updateLocatorFilter', $filter, $request); - - $filterAny = $this->config()->get('base_filter_any'); - $this->extend('updateLocatorFilterAny', $filterAny, $request); - - $exclude = $this->config()->get('base_exclude'); - $this->extend('updateLocatorExclude', $exclude, $request); - - $locations = Locator::get_locations($filter, $filterAny, $exclude); - $locations = DataToArrayListHelper::to_array_list($locations); - - //allow for adjusting list post possible distance calculation - $this->extend('updateLocationList', $locations); - - if ($locations->canSortBy('Distance')) { - $locations = $locations->sort('Distance'); - } - - if ($this->getShowRadius()) { - $radiusVar = Config::inst()->get(Locator::class, 'radius_var'); - - if ($radius = (int)$request->getVar($radiusVar)) { - $locations = $locations->filterByCallback(function ($location) use (&$radius) { - return $location->Distance <= $radius; - }); - } - } - - //allow for returning list to be set as - $this->extend('updateListType', $locations); - - $limit = $this->getLimit(); - if ($limit > 0) { - $locations = $locations->limit($limit); - } - - $this->locations = $locations; - - return $this; - - } - /** * @param HTTPRequest $request * @@ -319,29 +184,6 @@ public function getTrigger(HTTPRequest $request = null) return isset($trigger); } - /** - * @return ArrayData|boolean - */ - public function getAddressSearchCoords() - { - $addressVar = Config::inst()->get(DistanceDataExtension::class, 'address_var'); - if (!$this->request->getVar($addressVar)) { - return false; - } - if (class_exists(GoogleGeocoder::class)) { - $geocoder = new GoogleGeocoder($this->request->getVar($addressVar)); - $response = $geocoder->getResult(); - $lat = $response->getLatitude(); - $lng = $response->getLongitude(); - - return new ArrayData([ - "Lat" => $lat, - "Lng" => $lng, - ]); - } - - } - /** * LocationSearch form. * diff --git a/tests/Control/APIControllerTest.php b/tests/Control/APIControllerTest.php new file mode 100644 index 0000000..af241a3 --- /dev/null +++ b/tests/Control/APIControllerTest.php @@ -0,0 +1,249 @@ +assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest())); + } + + /** + * + */ + public function testXml() + { + /** @var APIController $controller */ + $controller = APIController::create(); + $page = $this->get($controller->Link('xml')); + + $this->assertEquals(200, $page->getStatusCode()); + $this->assertEquals('application/xml', $page->getHeader('content-type')); + + $dom = new DOMDocument(); + // true if it loads, false if it doesn't + $valid = $dom->loadXML($page->getBody()); + $this->assertTrue($valid); + } + + /** + * + */ + public function testJson() + { + /** @var APIController $controller */ + $controller = APIController::create(); + $page = $this->get($controller->Link('json')); + + $this->assertEquals(200, $page->getStatusCode()); + $this->assertEquals('application/json', $page->getHeader('content-type')); + + $json = json_decode($page->getBody()); + // if it is null its not valid + $this->assertNotNull($json); + } + + /** + * + */ + public function testGetLocations() + { + /** @var APIController $controller */ + $controller = APIController::create(); + + $filter = Config::inst()->get(APIController::class, 'base_filter'); + $filterAny = Config::inst()->get(APIController::class, 'base_filter_any'); + $exclude = Config::inst()->get(APIController::class, 'base_exclude'); + + $locations = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude); + $this->assertEquals($locations->count(), $controller->getLocationList($this->createRequest())->count()); + } + + /** + * + */ + public function testGetLocationList() + { + /** @var APIController $controller */ + $controller = APIController::create(); + + $filter = Config::inst()->get(APIController::class, 'base_filter'); + $filterAny = Config::inst()->get(APIController::class, 'base_filter_any'); + $exclude = Config::inst()->get(APIController::class, 'base_exclude'); + + $locations = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude); + $locationsB = $locations->limit(2); + + $this->assertEquals($locations->count(), $controller->getLocationList($this->createRequest(array( + 'Limit' => 2, + )))->count()); + + $this->assertEquals($locationsB->count(), $controller->getLocationList($this->createRequest(array( + 'Limit' => -50, + )))->count()); + } + + /** + * + */ + public function testGetFilter() + { + /** @var APIController $controller */ + $controller = APIController::create(); + $this->assertEquals(array(), $controller->getFilter($this->createRequest())); + + $this->assertEquals(array( + 'Categories.ID' => '1', + ), $controller->getFilter($this->createRequest(array( + 'CategoryID' => '1', + )))); + } + + /** + * + */ + public function testGetFilterAny() + { + /** @var APIController $controller */ + $controller = APIController::create(); + $request = $this->createRequest(); + + $this->assertEquals(array(), $controller->getFilterAny($request)); + + $controller->config()->update('base_filter_any', array( + 'Any' => 'one', + )); + + $this->assertEquals(array( + 'Any' => 'one', + ), $controller->getFilterAny($request)); + } + + /** + * + */ + public function testGetExclude() + { + /** @var APIController $controller */ + $controller = APIController::create(); + $request = $this->createRequest(); + + $this->assertEquals(array( + 'Lat' => 0, + 'Lng' => 0, + ), $controller->getExclude($request)); + + $controller->config()->update('base_exclude', array( + 'Any' => 'one', + )); + + $this->assertEquals(array( + 'Any' => 'one', + 'Lat' => 0, + 'Lng' => 0, + ), $controller->getExclude($request)); + } + + /** + * + */ + public function testGetLimit() + { + /** @var APIController $controller */ + $controller = APIController::create(); + + $this->assertEquals(50, $controller->getLimit($this->createRequest())); + + $this->assertEquals(50, $controller->getLimit( + $this->createRequest(array( + 'Limit' => 109, + )) + )); + + $this->assertEquals(25, $controller->getLimit( + $this->createRequest(array( + 'Limit' => 25, + )) + )); + } + + /** + * + */ + public function testLink() + { + /** @var APIController $controller */ + $controller = APIController::create(); + + Director::config()->set('rules', array( + 'api' => APIController::class, + )); + + $this->assertEquals('api/action', $controller->Link('action')); + } + + /** + * + */ + public function testGetRoute() + { + Director::config()->set('rules', array()); + $this->assertEquals('', APIController::getRoute()); + + Director::config()->set('rules', array( + 'api' => APIController::class, + )); + $this->assertEquals('api', APIController::getRoute()); + + Director::config()->set('rules', array( + 'api' => array( + 'Controller' => APIController::class, + ), + )); + $this->assertEquals('api', APIController::getRoute()); + } + + /** + * @param array $getVars + * @return \SilverStripe\Control\HTTPRequest + */ + private function createRequest($getVars = array()) + { + $link = APIController::create()->Link(); + + $request = new HTTPRequest('GET', $link, $getVars); + $session = new Session([]); + $request->setSession($session); + + return $request; + } +} diff --git a/tests/pages/LocatorControllerTest.php b/tests/pages/LocatorControllerTest.php index 024babd..24f2786 100644 --- a/tests/pages/LocatorControllerTest.php +++ b/tests/pages/LocatorControllerTest.php @@ -28,51 +28,6 @@ class LocatorControllerTest extends FunctionalTest */ protected static $use_draft_site = true; - /** - * - */ - public function testIndex() - { - $locator = $this->objFromFixture(Locator::class, 'locator1'); - $controller = LocatorController::create($locator); - $this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest())); - } - - /** - * - */ - public function testXml() - { - /** @var Locator $locator */ - $locator = $this->objFromFixture(Locator::class, 'locator1'); - $page = $this->get($locator->Link('xml')); - - $this->assertEquals(200, $page->getStatusCode()); - $this->assertEquals('application/xml', $page->getHeader('content-type')); - - $dom = new DOMDocument(); - // true if it loads, false if it doesn't - $valid = $dom->loadXML($page->getBody()); - $this->assertTrue($valid); - } - - /** - * - */ - public function testJson() - { - /** @var Locator $locator */ - $locator = $this->objFromFixture(Locator::class, 'locator1'); - $page = $this->get($locator->Link('json')); - - $this->assertEquals(200, $page->getStatusCode()); - $this->assertEquals('application/json', $page->getHeader('content-type')); - - $json = json_decode($page->getBody()); - // if it is null its not valid - $this->assertNotNull($json); - } - /** * */ diff --git a/tests/pages/LocatorTest.php b/tests/pages/LocatorTest.php index 80c67a7..972f25b 100644 --- a/tests/pages/LocatorTest.php +++ b/tests/pages/LocatorTest.php @@ -36,19 +36,6 @@ public function testGetCMSFields() $this->assertInstanceOf(FieldList::class, $locator->getCMSFields()); } - /** - * - */ - public function testLocations() - { - $filter = Config::inst()->get(LocatorController::class, 'base_filter'); - $filterAny = Config::inst()->get(LocatorController::class, 'base_filter_any'); - $exclude = Config::inst()->get(LocatorController::class, 'base_exclude'); - $locations = Locator::get_locations($filter, $filterAny, $exclude); - $locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude); - $this->assertEquals($locations->count(), $locations2->count()); - } - /** * */ @@ -119,16 +106,6 @@ public function testGetRadiiArrayList() $this->assertInstanceOf(ArrayList::class, $locator->getRadiiArrayList()); } - /** - * - */ - public function testGetLimit() - { - /** @var Locator $locator */ - $locator = Injector::inst()->create(Locator::class); - $this->assertEquals(50, $locator->getLimit()); - } - /** * */