You are here

public function GeolocationFieldTest::xxtestGeolocationFieldHtml5WidgetEmptyRequired in Geolocation Field 8

Helper function for testGeolocationField().

File

tests/src/Functional/GeolocationFieldTest.php, line 132

Class

GeolocationFieldTest
Tests the creation of geolocation fields.

Namespace

Drupal\Tests\geolocation\Functional

Code

public function xxtestGeolocationFieldHtml5WidgetEmptyRequired() {
  EntityFormDisplay::load('node.geolocation_default_article.default')
    ->setComponent('field_geolocation_demo_single', [
    'type' => 'geolocation_html5',
  ])
    ->save();
  EntityViewDisplay::load('node.geolocation_default_article.default')
    ->setComponent('field_geolocation_demo_single', [
    'type' => 'geolocation_latlng',
    'weight' => 1,
  ])
    ->save();

  // Display creation form.
  $this
    ->drupalGet('node/add/geolocation_default_article');
  $this
    ->assertSession()
    ->fieldExists("field_geolocation_demo_single[0][lat]");
  $this
    ->assertSession()
    ->fieldExists("field_geolocation_demo_single[0][lng]");
  $edit = [
    'title[0][value]' => $this
      ->randomMachineName(),
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('No location could be determined for required field Geolocation.');
}