function LocationGoogleGeocoderTest::testUSA in Location 7.5
Same name and namespace in other branches
- 6.3 tests/google_geocoder.test \LocationGoogleGeocoderTest::testUSA()
- 7.3 tests/google_geocoder.test \LocationGoogleGeocoderTest::testUSA()
- 7.4 tests/google_geocoder.test \LocationGoogleGeocoderTest::testUSA()
File
- tests/
google_geocoder.test, line 27
Class
Code
function testUSA() {
// Initialize the geocoder.
$settings = array(
'location_geocode_us' => 'google',
);
$this
->drupalPost('admin/settings/location/geocoding', $settings, 'Save configuration');
$this
->refreshVariables();
$settings = array();
$location_type = $this
->addLocationContentType($settings);
$location1_name = $this
->randomName();
$node = $this
->drupalCreateNode(array(
'type' => $location_type,
'locations' => array(
0 => array(
'name' => $location1_name,
'location_settings' => $settings,
'street' => '1600 Amphitheatre Parkway',
'city' => 'Mountain View',
'province' => 'CA',
'postal_code' => '94043',
'country' => 'us',
),
),
));
// Reload the node.
$node2 = node_load($node->nid, NULL, TRUE);
$location = $node2->locations[0];
$this
->assertEqual($location['source'], LOCATION_LATLON_GEOCODED_EXACT);
$expected = array(
37.421972,
-122.084143,
);
$result = array(
$location['latitude'],
$location['longitude'],
);
$this
->assertArrayEpsilon($result, $expected, 0.01, 'Google Headquarters');
}