You are here

function GeofieldFormatterTestCase::testGeofieldDefFormatter in Geofield 7.2

File

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

Class

GeofieldFormatterTestCase

Code

function testGeofieldDefFormatter() {

  // Test lat/lon widget
  $this
    ->_testGeoFieldAPISetup('geofield_wkt', 'geofield_def_list');

  // Display creation form.
  $langcode = LANGUAGE_NONE;
  $this
    ->drupalGet('test-entity/add/test-bundle');

  // Submit with some value.
  include_once drupal_get_path('module', 'geofield') . '/includes/GeoGenerator.php';
  $generator = new GeoGenerator();
  $wkt = $generator
    ->wkt_generate();
  geophp_load();
  $geometry = geoPHP::load($wkt, 'wkt');
  $edit = array(
    "{$this->field_name}[{$langcode}][0][geom]" => $geometry
      ->out('wkt'),
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  preg_match('|test-entity/manage/(\\d+)/edit|', $this->url, $match);
  $id = $match[1];

  // Test GeoJSON output
  $entity = field_test_entity_test_load($id);
  $entity->content = field_attach_view('test_entity', $entity, 'full');
  $this->content = drupal_render($entity->content);

  // @TODO: Actually test output... :-/
}