You are here

google_geocoder.test in Location 7.3

File

tests/google_geocoder.test
View source
<?php

/**
 * @file
 * Location saving test.
 */
require_once drupal_get_path('module', 'location') . '/tests/location_testcase.test';
require_once drupal_get_path('module', 'location') . '/tests/geocoder_api_keys.inc';

/**
 * Class LocationGoogleGeocoderTest.
 */
class LocationGoogleGeocoderTest extends LocationTestCase {
  public static function getInfo() {
    return array(
      'name' => t('Location Google Geocoder tests(broken!!!)'),
      'description' => t('Test address mangling for the google geocoder.'),
      'group' => t('Location', array(), array(
        'context' => 'geolocation',
      )),
    );
  }
  public function setUp() {
    parent::setUp('location', 'location_node', 'devel');
    variable_set('location_geocode_google_apikey', TESTING_APIKEY_GOOGLE_MAPS);
    $web_admin = $this
      ->drupalCreateUser(array_keys(module_invoke_all('permission')));
    $this
      ->drupalLogin($web_admin);
  }
  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');
  }

}

Classes

Namesort descending Description
LocationGoogleGeocoderTest Class LocationGoogleGeocoderTest.