function test_service_unavailable() { $url = 'http://api.hostip.info/get_html.php?ip=0.0.0.0&position=true'; $ip_geocoder = new IpGeocoder(); $response = $ip_geocoder->call_geocoder_service($url); $this->assertEqual($response['body'], $this->ip_failure); $location = $ip_geocoder->geocode('0.0.0.0'); $this->assertFalse($location->success); }
function test_no_location_in_cookie_or_session() { # GeoKit::Geocoders::IpGeocoder.expects(:geocode).with("good ip").returns(@success) # @request.remote_ip = "good ip" # get :index # verify $good_ip = "12.215.42.19"; $ip_geocoder = new IpGeocoder(); $address = $ip_geocoder->geocode($good_ip); $this->request->remote_ip = $good_ip; # $response = $this->request->get('body'); #print_r($response); # $this->assertEqual($response['body'],$this->success); # $this->verify(); }
private function retrieve_location_from_cookie_or_service() { if (isset($_COOKIE['geo_location'])) { $yaml_to_array = new AkYamlToArray(); $yaml_to_array->source = $_COOKIE['geo_location']; return new GeoLoc($yaml_to_array->convert()); } $location = IpGeocoder::geocode(get_ip_address()); if ($location->success) { return $location; } return null; }
private function geocode_ip_address($origin) { $geo_location = IpGeocoder::geocode($origin); if ($geo_location->success) { return $geo_location; } $msg = "Couldn't geocode ip address: " . $origin; new GeocodeError($msg); }
function ip_geocoder($address) { return IpGeocoder::do_geocode($address); }