You are here

function GeoFieldElementTestCase::testGeofieldLatLonElement in Geofield 7.2

File

tests/geofield.test, line 259
Tests for geofield.module.

Class

GeoFieldElementTestCase

Code

function testGeofieldLatLonElement() {

  // Test form element rendering
  $this
    ->drupalGet('geofield-latlon-element');
  $this
    ->assertFieldById('edit-geofield-latlon-simple-lat', '', 'Latitude element for simple geofield exists.');
  $this
    ->assertFieldById('edit-geofield-latlon-simple-lon', '', 'Longitude element for simple geofield exists.');
  $this
    ->assertFieldById('edit-geofield-latlon-verbose-lat', 41, 'Latitude element for verbose geofield exists.');
  $this
    ->assertFieldById('edit-geofield-latlon-verbose-lon', -86, 'Longitude element for verbose geofield exists.');

  // Test form element submission.
  $edit = array();
  $edit['geofield_latlon_simple[lat]'] = 41;
  $edit['geofield_latlon_simple[lon]'] = -86;
  $edit['geofield_latlon_verbose[lat]'] = 25;
  $edit['geofield_latlon_verbose[lon]'] = 54;
  $this
    ->drupalPost('geofield-latlon-element', $edit, t('Save'));
  $this
    ->assertText('Simple - Lat: 41 Lon: -86', "Simple Geofield saved data as expected");
  $this
    ->assertText('Verbose - Lat: 25 Lon: 54', "Verbose Geofield saved data as expected");
}