You are here

earth.test in Location 7.3

File

tests/earth.test
View source
<?php

/**
 * @file
 * Tests for earth.inc functionality.
 */
require_once drupal_get_path('module', 'location') . '/earth.inc';
require_once drupal_get_path('module', 'location') . '/tests/location_testcase.test';
class LocationEarthTest extends LocationTestCase {
  public static function getInfo() {
    return array(
      'name' => t('Location earth.inc tests'),
      'description' => t('Test earth.inc calculations.'),
      'group' => t('Location', array(), array(
        'context' => 'geolocation',
      )),
    );
  }
  public function setUp() {
    parent::setUp('location', 'location_node', 'devel');
  }
  public function testXYZ() {
    $expected = array(
      5076436.1926031,
      3086400.2318368,
      2312685.5571307,
    );
    $result = earth_xyz(31.299, 21.4);
    $this
      ->assertArrayEpsilon($result, $expected, 0.01);

    // Taj Mahal
    $expected = array(
      1179389.7524227,
      605469.92806515,
      6217918.5984722,
    );
    $result = earth_xyz(27.174858, 78.042383);
    $this
      ->assertArrayEpsilon($result, $expected, 0.01, 'Taj Mahal');

    // Four Corners
    $expected = array(
      -1667195.89356,
      -1256280.4293852,
      -6006637.16009,
    );
    $result = earth_xyz(36.999084, -109.045223);
    $this
      ->assertArrayEpsilon($result, $expected, 0.01, 'Four Corners');

    // North Magnetic Pole
    $expected = array(
      -335727.75631839,
      -2620765.1318567,
      -5785664.2896111,
    );
    $result = earth_xyz(82.7, -114.4);
    $this
      ->assertArrayEpsilon($result, $expected, 0.01, 'North Magnetic Pole');

    // Wall Drug
    $expected = array(
      -976074.7749119099,
      -942362.77881868,
      -6211268.2459008,
    );
    $result = earth_xyz(43.993266, -102.241794);
    $this
      ->assertArrayEpsilon($result, $expected, 0.01, 'Wall Drug');
  }

}

Classes

Namesort descending Description
LocationEarthTest