From 0c5d79695887c12a57b4d9d0dc9d7d9f30bfaefc Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 10 Mar 2017 07:44:08 +1100 Subject: [PATCH 1/3] CRM-20023 Add test showing passing in just state_province_id and country only geoloates based on country not state as well --- tests/phpunit/CRM/Utils/GeocodeTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/phpunit/CRM/Utils/GeocodeTest.php diff --git a/tests/phpunit/CRM/Utils/GeocodeTest.php b/tests/phpunit/CRM/Utils/GeocodeTest.php new file mode 100644 index 000000000000..a94db81f12d2 --- /dev/null +++ b/tests/phpunit/CRM/Utils/GeocodeTest.php @@ -0,0 +1,24 @@ + 1022, 'country' => 'U.S.A'); + $formatted = CRM_Utils_Geocode_Google::format($params); + $this->assertTrue($formatted); + $this->assertEquals('46.729553', $params['geo_code_1']); + $this->assertEquals('-94.6858998', $params['geo_code_2']); + } + +} From 0aef9f5a26b34f66f9b9cf5b8139e72614fe3a23 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 10 Mar 2017 08:17:36 +1100 Subject: [PATCH 2/3] Fix tear down function --- tests/phpunit/CRM/Utils/GeocodeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Utils/GeocodeTest.php b/tests/phpunit/CRM/Utils/GeocodeTest.php index a94db81f12d2..c41f96944d90 100644 --- a/tests/phpunit/CRM/Utils/GeocodeTest.php +++ b/tests/phpunit/CRM/Utils/GeocodeTest.php @@ -9,8 +9,8 @@ public function setUp() { parent::setUp(); } - public function tareDown() { - parent::tareDown(); + public function tearDown() { + parent::tearDown(); } public function testStateProvinceFormat() { From 61e0e289d6c8e6da513b53440625cb29f031a052 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 10 Mar 2017 09:40:37 +1100 Subject: [PATCH 3/3] Use assertApproxEquals as per Tim's suggestion --- tests/phpunit/CRM/Utils/GeocodeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Utils/GeocodeTest.php b/tests/phpunit/CRM/Utils/GeocodeTest.php index c41f96944d90..980cb2830910 100644 --- a/tests/phpunit/CRM/Utils/GeocodeTest.php +++ b/tests/phpunit/CRM/Utils/GeocodeTest.php @@ -17,8 +17,8 @@ public function testStateProvinceFormat() { $params = array('state_province_id' => 1022, 'country' => 'U.S.A'); $formatted = CRM_Utils_Geocode_Google::format($params); $this->assertTrue($formatted); - $this->assertEquals('46.729553', $params['geo_code_1']); - $this->assertEquals('-94.6858998', $params['geo_code_2']); + $this->assertApproxEquals('46.72', $params['geo_code_1'], 1); + $this->assertApproxEquals('-94.68', $params['geo_code_2'], 1); } }