|
|
@@ -15,6 +15,52 @@ Configure::write('Google', array(
|
|
|
|
|
|
class GeocodeLibTest extends MyCakeTestCase {
|
|
|
|
|
|
+ public $apiMockupReverseGeocode40206 = array(
|
|
|
+ 'reverseGeocode' => array(
|
|
|
+ 'lat' => '38.2643',
|
|
|
+ 'lng' => '-85.6999',
|
|
|
+ 'params' => array(
|
|
|
+ 'address' => '40206',
|
|
|
+ 'latlng' => '',
|
|
|
+ 'region' => '',
|
|
|
+ 'language' => 'en',
|
|
|
+ 'bounds' => '',
|
|
|
+ 'sensor' => 'false',
|
|
|
+ 'key' => 'AIzaSyAcQWSeMp_RF9W2_g2vOfLlUNCieHtHfFA',
|
|
|
+ 'result_type' => 'sublocality'
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ '_fetch' => 'https://maps.googleapis.com/maps/api/geocode/json?address=40206&latlng=38.2643%2C-85.6999&language=en&sensor=false',
|
|
|
+ 'raw' => '{
|
|
|
+ "results" : [
|
|
|
+ {
|
|
|
+ "address_components" : [
|
|
|
+ { "long_name" : "40206", "short_name" : "40206", "types" : [ "postal_code" ] },
|
|
|
+ { "long_name" : "Louisville", "short_name" : "Louisville", "types" : [ "locality", "political" ] },
|
|
|
+ { "long_name" : "Kentucky", "short_name" : "KY", "types" : [ "administrative_area_level_1", "political" ] },
|
|
|
+ { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] }
|
|
|
+ ],
|
|
|
+ "formatted_address" : "Louisville, KY 40206, USA",
|
|
|
+ "geometry" : {
|
|
|
+ "bounds" : {
|
|
|
+ "northeast" : { "lat" : 38.2852558, "lng" : -85.664309 },
|
|
|
+ "southwest" : { "lat" : 38.2395658, "lng" : -85.744801 }
|
|
|
+ },
|
|
|
+ "location" : { "lat" : 38.26435780000001, "lng" : -85.69997889999999 },
|
|
|
+ "location_type" : "APPROXIMATE",
|
|
|
+ "viewport" : {
|
|
|
+ "northeast" : { "lat" : 38.2852558, "lng" : -85.664309 },
|
|
|
+ "southwest" : { "lat" : 38.2395658, "lng" : -85.744801 }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "types" : [ "postal_code" ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "status" : "OK"
|
|
|
+ }',
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
public function setUp() {
|
|
|
parent::setUp();
|
|
|
|
|
|
@@ -31,6 +77,105 @@ class GeocodeLibTest extends MyCakeTestCase {
|
|
|
$this->assertInstanceOf('GeocodeLib', $this->Geocode);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testReverseGeocode()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testReverseGeocode() {
|
|
|
+ $coords = array(
|
|
|
+ array(-34.594445, -58.37446, 'Calle Florida 1134-1200, Buenos Aires'),
|
|
|
+ array(48.8934, 8.70492, 'B294, 75175 Pforzheim, Deutschland')
|
|
|
+ );
|
|
|
+
|
|
|
+ foreach ($coords as $coord) {
|
|
|
+ $is = $this->Geocode->reverseGeocode($coord[0], $coord[1]);
|
|
|
+ $this->assertTrue($is);
|
|
|
+
|
|
|
+ $is = $this->Geocode->getResult();
|
|
|
+ $this->assertTrue(!empty($is));
|
|
|
+ //debug($is);
|
|
|
+ $address = isset($is[0]) ? $is[0]['formatted_address'] : $is['formatted_address'];
|
|
|
+ $this->assertTextContains($coord[2], $address);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Seems to return
|
|
|
+ * - 'Bibersfelder Besen Weinstube, Luckenbacher Straße 1, 74523 Schwäbisch Hall, Deutschland'
|
|
|
+ * - point_of_interest, school, establishment
|
|
|
+ * - 'Bibersfeld, 74523 Schwäbisch Hall, Deutschland'
|
|
|
+ * - sublocality, political
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGeocodeInconclusive() {
|
|
|
+ $address = 'Bibersfeld';
|
|
|
+
|
|
|
+ $this->Geocode->setOptions(array('allow_inconclusive' => true, 'min_accuracy' => GeocodeLib::ACC_POSTAL));
|
|
|
+ $is = $this->Geocode->geocode($address);
|
|
|
+ $this->assertTrue($is);
|
|
|
+ $res = $this->Geocode->getResult();
|
|
|
+
|
|
|
+ $is = $this->Geocode->isInconclusive();
|
|
|
+ $this->assertFalse($is);
|
|
|
+
|
|
|
+ // Fake inconclusive here by adding an additional type
|
|
|
+ $this->Geocode->accuracyTypes[99] = 'point_of_interest';
|
|
|
+ $this->Geocode->setOptions(array('allow_inconclusive' => false));
|
|
|
+ $is = $this->Geocode->geocode($address);
|
|
|
+ $this->assertFalse($is);
|
|
|
+
|
|
|
+ $is = $this->Geocode->isInconclusive();
|
|
|
+ $this->assertTrue($is);
|
|
|
+
|
|
|
+ $res = $this->Geocode->getResult();
|
|
|
+ $this->assertSame(2, $res['valid_results']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * With lower min accuracy
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGeocodeInconclusiveMinAccuracy() {
|
|
|
+ $address = 'Bibersfeld';
|
|
|
+
|
|
|
+ $this->Geocode->setOptions(array('allow_inconclusive' => true, 'min_accuracy' => GeocodeLib::ACC_STREET));
|
|
|
+ $is = $this->Geocode->geocode($address);
|
|
|
+ $this->assertFalse($is);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Seems to return
|
|
|
+ * - 'Bibersfelder Besen Weinstube, Luckenbacher Straße 1, 74523 Schwäbisch Hall, Deutschland'
|
|
|
+ * - point_of_interest, school, establishment
|
|
|
+ * - 'Bibersfeld, 74523 Schwäbisch Hall, Deutschland'
|
|
|
+ * - sublocality, political
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGeocodeExpect() {
|
|
|
+ $address = 'Bibersfeld';
|
|
|
+
|
|
|
+ $this->Geocode->setOptions(array(
|
|
|
+ 'allow_inconclusive' => true,
|
|
|
+ 'expect' => array(GeocodeLib::ACC_POSTAL, GeocodeLib::ACC_LOC, GeocodeLib::ACC_SUBLOC)));
|
|
|
+ $is = $this->Geocode->geocode($address);
|
|
|
+ $this->assertTrue($is);
|
|
|
+
|
|
|
+ $this->Geocode->setOptions(array(
|
|
|
+ 'allow_inconclusive' => true,
|
|
|
+ 'expect' => array(GeocodeLib::ACC_POSTAL, GeocodeLib::ACC_LOC)));
|
|
|
+ $is = $this->Geocode->geocode($address);
|
|
|
+ $this->assertFalse($is);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testDistance()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testDistance() {
|
|
|
$coords = array(
|
|
|
array('name' => 'MUC/Pforzheim (269km road, 2:33h)', 'x' => array('lat' => 48.1391, 'lng' => 11.5802), 'y' => array('lat' => 48.8934, 'lng' => 8.70492), 'd' => 228),
|
|
|
@@ -46,6 +191,11 @@ class GeocodeLibTest extends MyCakeTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testBlur()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testBlur() {
|
|
|
$coords = array(
|
|
|
array(48.1391, 1, 0.002), //'y'=>array('lat'=>48.8934, 'lng'=>8.70492), 'd'=>228),
|
|
|
@@ -59,6 +209,11 @@ class GeocodeLibTest extends MyCakeTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testConvert()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testConvert() {
|
|
|
$values = array(
|
|
|
array(3, 'M', 'K', 4.828032),
|
|
|
@@ -73,53 +228,50 @@ class GeocodeLibTest extends MyCakeTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testUrl()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testUrl() {
|
|
|
- $is = $this->Geocode->url();
|
|
|
- //debug($is);
|
|
|
- $this->assertTrue(!empty($is) && strpos($is, 'http://maps.googleapis.com/maps/api/geocode/xml?') === 0);
|
|
|
- }
|
|
|
-
|
|
|
- // not possible with protected method
|
|
|
-
|
|
|
- public function _testFetch() {
|
|
|
- $url = 'http://maps.google.com/maps/api/geocode/xml?sensor=false&address=74523';
|
|
|
- $is = $this->Geocode->_fetch($url);
|
|
|
- //debug($is);
|
|
|
+ $ReflectionClass = new ReflectionClass('GeocodeLib');
|
|
|
+ $Method = $ReflectionClass->getMethod('_url');
|
|
|
+ $Method->setAccessible(true);
|
|
|
|
|
|
- $this->assertTrue(!empty($is) && substr($is, 0, 38) === '<?xml version="1.0" encoding="UTF-8"?>');
|
|
|
-
|
|
|
- $url = 'http://maps.google.com/maps/api/geocode/json?sensor=false&address=74523';
|
|
|
- $is = $this->Geocode->_fetch($url);
|
|
|
- //debug($is);
|
|
|
- $this->assertTrue(!empty($is) && substr($is, 0, 1) === '{');
|
|
|
+ $is = $Method->invoke($this->Geocode);
|
|
|
+ $this->assertPattern('#https://maps.googleapis.com/maps/api/geocode/json#', $is);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testSetParams()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testSetParams() {
|
|
|
}
|
|
|
|
|
|
- public function testWithJson() {
|
|
|
- $this->Geocode->setOptions(array('output' => 'json'));
|
|
|
- $address = '74523 Deutschland';
|
|
|
- //echo '<h2>'.$address.'</h2>';
|
|
|
- $is = $this->Geocode->geocode($address);
|
|
|
- $this->assertTrue($is);
|
|
|
-
|
|
|
- $is = $this->Geocode->getResult();
|
|
|
- //debug($is);
|
|
|
- $this->assertTrue(!empty($is));
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testSetOptions()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testSetOptions() {
|
|
|
- // should be the default
|
|
|
- $res = $this->Geocode->url();
|
|
|
- $this->assertTextContains('maps.googleapis.com', $res);
|
|
|
-
|
|
|
$this->Geocode->setOptions(array('host' => 'maps.google.it'));
|
|
|
+
|
|
|
// should now be ".it"
|
|
|
- $res = $this->Geocode->url();
|
|
|
- $this->assertTextContains('maps.google.it', $res);
|
|
|
+ $ReflectionClass = new ReflectionClass('GeocodeLib');
|
|
|
+ $Method = $ReflectionClass->getMethod('_url');
|
|
|
+ $Method->setAccessible(true);
|
|
|
+
|
|
|
+ $result = $Method->invoke($this->Geocode);
|
|
|
+ $this->assertTextContains('maps.google.it', $result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testGeocode()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testGeocode() {
|
|
|
$address = '74523 Deutschland';
|
|
|
//echo '<h2>'.$address.'</h2>';
|
|
|
@@ -168,78 +320,198 @@ class GeocodeLibTest extends MyCakeTestCase {
|
|
|
$this->assertTrue(empty($is));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testGeocodeBadApiKey()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGeocodeBadApiKey() {
|
|
|
+ $address = 'Oranienburger Straße 87, 10178 Berlin, Deutschland';
|
|
|
+ $result = $this->Geocode->geocode($address, array('sensor' => false, 'key' => 'testingBadApiKey'));
|
|
|
+ $this->assertFalse($result);
|
|
|
+
|
|
|
+ $result = $this->Geocode->error();
|
|
|
+ $this->assertEquals('Error REQUEST_DENIED (The provided API key is invalid.)', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testGeocodeInvalid()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
public function testGeocodeInvalid() {
|
|
|
$address = 'Hjfjosdfhosj, 78878 Mdfkufsdfk';
|
|
|
- //echo '<h2>'.$address.'</h2>';
|
|
|
- $is = $this->Geocode->geocode($address);
|
|
|
- //debug($is);
|
|
|
- $this->assertFalse($is);
|
|
|
-
|
|
|
- //pr($this->Geocode->debug());
|
|
|
+ $result = $this->Geocode->geocode($address);
|
|
|
+ $this->assertFalse($result);
|
|
|
|
|
|
- $is = $this->Geocode->error();
|
|
|
- //debug($is);
|
|
|
- $this->assertTrue(!empty($is));
|
|
|
+ $result = $this->Geocode->error();
|
|
|
+ $this->assertTrue(!empty($result));
|
|
|
}
|
|
|
|
|
|
- public function testGeocodeMinAcc() {
|
|
|
- $address = 'Deutschland';
|
|
|
- //echo '<h2>'.$address.'</h2>';
|
|
|
- $this->Geocode->setOptions(array('min_accuracy' => 3));
|
|
|
- $is = $this->Geocode->geocode($address);
|
|
|
- //debug($is);
|
|
|
- $this->assertFalse($is);
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testGetMaxAddress()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetMaxAddress() {
|
|
|
+ $ReflectionClass = new ReflectionClass('GeocodeLib');
|
|
|
+ $Method = $ReflectionClass->getMethod('_getMaxAccuracy');
|
|
|
+ $Method->setAccessible(true);
|
|
|
|
|
|
- $is = $this->Geocode->error();
|
|
|
- //debug($is);
|
|
|
- $this->assertTrue(!empty($is));
|
|
|
- }
|
|
|
+ $result = $Method->invoke($this->Geocode, array('street_address' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_STREET, $result);
|
|
|
|
|
|
- public function testGeocodeInconclusive() {
|
|
|
- // seems like there is no inconclusive result anymore!!!
|
|
|
+ $result = $Method->invoke($this->Geocode, array('intersection' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_INTERSEC, $result);
|
|
|
|
|
|
- $address = 'Neustadt';
|
|
|
- //echo '<h2>'.$address.'</h2>';
|
|
|
+ $result = $Method->invoke($this->Geocode, array('route' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_ROUTE, $result);
|
|
|
|
|
|
- // allow_inconclusive = TRUE
|
|
|
- $this->Geocode->setOptions(array('allow_inconclusive' => true, 'min_accuracy' => GeocodeLib::ACC_LOC));
|
|
|
- $is = $this->Geocode->geocode($address);
|
|
|
- //echo 'debug:';
|
|
|
- //pr($this->Geocode->debug());
|
|
|
- //echo 'debug end';
|
|
|
- $this->assertTrue($is);
|
|
|
+ $result = $Method->invoke($this->Geocode, array('sublocality' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_SUBLOC, $result);
|
|
|
|
|
|
- $res = $this->Geocode->getResult();
|
|
|
- //pr($res);
|
|
|
- $this->assertTrue(count($res) > 4);
|
|
|
+ $result = $Method->invoke($this->Geocode, array('locality' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_LOC, $result);
|
|
|
|
|
|
- $is = $this->Geocode->isInconclusive();
|
|
|
- $this->assertTrue($is);
|
|
|
+ $result = $Method->invoke($this->Geocode, array('postal_code' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_POSTAL, $result);
|
|
|
|
|
|
- $this->Geocode->setOptions(array('allow_inconclusive' => false));
|
|
|
+ $result = $Method->invoke($this->Geocode, array('country' => 'abc'));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_COUNTRY, $result);
|
|
|
+
|
|
|
+ $result = $Method->invoke($this->Geocode, array());
|
|
|
+ $this->assertSame(null, $result);
|
|
|
+
|
|
|
+ // mixed
|
|
|
+ $result = $Method->invoke($this->Geocode, array(
|
|
|
+ 'country' => 'aa',
|
|
|
+ 'postal_code' => 'abc',
|
|
|
+ 'locality' => '',
|
|
|
+ 'street_address' => '',
|
|
|
+ ));
|
|
|
+ $this->assertSame(GeocodeLib::ACC_POSTAL, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testGeocodeMinAcc()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGeocodeMinAcc() {
|
|
|
+ // address = postal_code, minimum = street level
|
|
|
+ $address = 'Deutschland';
|
|
|
+ $this->Geocode->setOptions(array('min_accuracy' => GeocodeLib::ACC_STREET));
|
|
|
$is = $this->Geocode->geocode($address);
|
|
|
$this->assertFalse($is);
|
|
|
+ $is = $this->Geocode->error();
|
|
|
+ $this->assertTrue(!empty($is));
|
|
|
}
|
|
|
|
|
|
- public function testReverseGeocode() {
|
|
|
- $coords = array(
|
|
|
- array(-34.594445, -58.37446, 'Calle Florida 1134-1200, Buenos Aires'),
|
|
|
- array(48.8934, 8.70492, 'B294, 75175 Pforzheim, Deutschland')
|
|
|
+ /**
|
|
|
+ * GeocodeLibTest::testTransformData()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTransformData() {
|
|
|
+ $ReflectionClass = new ReflectionClass('GeocodeLib');
|
|
|
+ $Method = $ReflectionClass->getMethod('_transformData');
|
|
|
+ $Method->setAccessible(true);
|
|
|
+
|
|
|
+ // non-full records
|
|
|
+ $data = array('types' => array());
|
|
|
+ $this->assertEquals($data, $Method->invoke($this->Geocode, $data));
|
|
|
+ $data = array();
|
|
|
+ $this->assertEquals($data, $Method->invoke($this->Geocode, $data));
|
|
|
+
|
|
|
+ // Full record
|
|
|
+ $ReflectionClass = new ReflectionClass('GeocodeLib');
|
|
|
+ $Method = $ReflectionClass->getMethod('_transform');
|
|
|
+ $Method->setAccessible(true);
|
|
|
+ $data = json_decode($this->apiMockupReverseGeocode40206['raw'], true);
|
|
|
+ $expected = array(
|
|
|
+ 'results' => array(
|
|
|
+ array(
|
|
|
+ 'formatted_address' => 'Louisville, KY 40206, USA',
|
|
|
+ // organized location components
|
|
|
+ 'country' => 'United States',
|
|
|
+ 'country_code' => 'US',
|
|
|
+ 'country_province' => 'Kentucky',
|
|
|
+ 'country_province_code' => 'KY',
|
|
|
+ 'postal_code' => '40206',
|
|
|
+ 'locality' => 'Louisville',
|
|
|
+ 'sublocality' => '',
|
|
|
+ 'route' => '',
|
|
|
+ // vetted "types"
|
|
|
+ 'types' => array(
|
|
|
+ 'postal_code',
|
|
|
+ ),
|
|
|
+ // simple lat/lng
|
|
|
+ 'lat' => 38.264357800000013,
|
|
|
+ 'lng' => -85.699978899999991,
|
|
|
+ 'location_type' => 'APPROXIMATE',
|
|
|
+ 'viewport' => array(
|
|
|
+ 'sw' => array(
|
|
|
+ 'lat' => 38.239565800000001,
|
|
|
+ 'lng' => -85.744800999999995,
|
|
|
+ ),
|
|
|
+ 'ne' => array(
|
|
|
+ 'lat' => 38.285255800000002,
|
|
|
+ 'lng' => -85.664309000000003,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'bounds' => array(
|
|
|
+ 'sw' => array(
|
|
|
+ 'lat' => 38.239565800000001,
|
|
|
+ 'lng' => -85.744800999999995,
|
|
|
+ ),
|
|
|
+ 'ne' => array(
|
|
|
+ 'lat' => 38.285255800000002,
|
|
|
+ 'lng' => -85.664309000000003,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'address_components' => array(
|
|
|
+ array(
|
|
|
+ 'long_name' => '40206',
|
|
|
+ 'short_name' => '40206',
|
|
|
+ 'types' => array(
|
|
|
+ 'postal_code',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ array(
|
|
|
+ 'long_name' => 'Louisville',
|
|
|
+ 'short_name' => 'Louisville',
|
|
|
+ 'types' => array(
|
|
|
+ 'locality',
|
|
|
+ 'political',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ array(
|
|
|
+ 'long_name' => 'Kentucky',
|
|
|
+ 'short_name' => 'KY',
|
|
|
+ 'types' => array(
|
|
|
+ 'administrative_area_level_1',
|
|
|
+ 'political',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ array(
|
|
|
+ 'long_name' => 'United States',
|
|
|
+ 'short_name' => 'US',
|
|
|
+ 'types' => array(
|
|
|
+ 'country',
|
|
|
+ 'political',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'valid_type' => true,
|
|
|
+ 'accuracy' => 4,
|
|
|
+ 'accuracy_name' => 'postal_code',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'status' => 'OK',
|
|
|
);
|
|
|
+ $result = $Method->invoke($this->Geocode, $data);
|
|
|
|
|
|
- foreach ($coords as $coord) {
|
|
|
- $is = $this->Geocode->reverseGeocode($coord[0], $coord[1]);
|
|
|
- $this->assertTrue($is);
|
|
|
-
|
|
|
- $is = $this->Geocode->getResult();
|
|
|
- $this->assertTrue(!empty($is));
|
|
|
- //debug($is);
|
|
|
- $address = isset($is[0]) ? $is[0]['formatted_address'] : $is['formatted_address'];
|
|
|
- $this->assertTextContains($coord[2], $address);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function testGetResult() {
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
}
|
|
|
|
|
|
}
|