You are here

public function GeolocationTokenFormatterTest::testGeocoderTokenizedTestReplacement in Geolocation Field 8

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

Tests the token formatter.

File

tests/src/FunctionalJavascript/GeolocationTokenFormatterTest.php, line 81

Class

GeolocationTokenFormatterTest
Tests the Google Geocoder Token Formatter functionality.

Namespace

Drupal\Tests\geolocation\FunctionalJavascript

Code

public function testGeocoderTokenizedTestReplacement() {
  $this
    ->drupalGetFilterGoogleKey('node/1');
  $this
    ->assertSession()
    ->responseContains('<span class="geolocation-latlng">52, 47</span>');
  EntityViewDisplay::load('node.article.default')
    ->setComponent('field_geolocation', [
    'type' => 'geolocation_token',
    'settings' => [
      'tokenized_text' => '<h1 class="testingtitle">[geolocation_current_item:data:title]</h1><div class="testing">[geolocation_current_item:lat]/[geolocation_current_item:lng]</div>',
    ],
    'weight' => 1,
  ])
    ->save();
  $this
    ->drupalGetFilterGoogleKey('node/1');
  $this
    ->assertSession()
    ->responseContains('<div class="testing">52/47</div>');
  $this
    ->assertSession()
    ->responseContains('<h1 class="testingtitle">My home</h1>');
}