You are here

public function GeolocationGoogleGeocoderWidgetTest::testGeocoderWidgetEmptyValuePreserved in Geolocation Field 8

Same name and namespace in other branches
  1. 8.3 tests/src/FunctionalJavascript/GeolocationGoogleGeocoderWidgetTest.php \Drupal\Tests\geolocation\FunctionalJavascript\GeolocationGoogleGeocoderWidgetTest::testGeocoderWidgetEmptyValuePreserved()
  2. 8.2 tests/src/FunctionalJavascript/GeolocationGoogleGeocoderWidgetTest.php \Drupal\Tests\geolocation\FunctionalJavascript\GeolocationGoogleGeocoderWidgetTest::testGeocoderWidgetEmptyValuePreserved()

Tests the Google Maps widget.

File

tests/src/FunctionalJavascript/GeolocationGoogleGeocoderWidgetTest.php, line 141

Class

GeolocationGoogleGeocoderWidgetTest
Tests the Google Geocoder Widget functionality.

Namespace

Drupal\Tests\geolocation\FunctionalJavascript

Code

public function testGeocoderWidgetEmptyValuePreserved() {
  EntityFormDisplay::load('node.article.default')
    ->setComponent('field_geolocation', [
    'type' => 'geolocation_googlegeocoder',
    'settings' => [
      'default_latitude' => 12,
      'default_longitude' => 24,
    ],
  ])
    ->save();
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGetFilterGoogleKey('node/add/article');
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->findField('Title')
    ->setValue('I am new');
  $page
    ->pressButton('Save');

  /** @var \Drupal\node\NodeInterface $new_node */
  $new_node = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->load(5);
  $this
    ->assertSession()
    ->assert($new_node
    ->get('field_geolocation')
    ->isEmpty(), "Node geolocation field empty after saving from predefined location widget");
}