You are here

public function LocationGoogleGeocoderTest::testUSA in Location 7.3

Same name and namespace in other branches
  1. 6.3 tests/google_geocoder.test \LocationGoogleGeocoderTest::testUSA()
  2. 7.5 tests/google_geocoder.test \LocationGoogleGeocoderTest::testUSA()
  3. 7.4 tests/google_geocoder.test \LocationGoogleGeocoderTest::testUSA()

File

tests/google_geocoder.test, line 31

Class

LocationGoogleGeocoderTest
Class LocationGoogleGeocoderTest.

Code

public function testUSA() {

  // Initialize the geocoder.
  $settings = array(
    'location_geocode_us' => 'google',
  );
  $this
    ->drupalPost('admin/config/content/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];

  // @todo fixme

  //$this->assertEqual($location['source'], LOCATION_LATLON_GEOCODED_EXACT);

  // @todo remove debug
  $this
    ->pass('<pre>' . print_r($node2, TRUE) . '</pre>', 'Debug');
  $expected = array(
    37.421972,
    -122.084143,
  );
  $result = array(
    $location['latitude'],
    $location['longitude'],
  );

  // @todo fixme

  //$this->assertArrayEpsilon($result, $expected, 0.01, 'Google Headquarters');
}