You are here

public function GeolocationTokenFormatterTest::testGeocoderTokenizedTestReplacement in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8 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 82

Class

GeolocationTokenFormatterTest
Tests the Token Formatter functionality.

Namespace

Drupal\Tests\geolocation\FunctionalJavascript

Code

public function testGeocoderTokenizedTestReplacement() {
  $this
    ->drupalGet('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' => [
        'value' => 'Title: [geolocation_current_item:data:title] Lat/Lng: [geolocation_current_item:lat]/[geolocation_current_item:lng]',
        'format' => filter_default_format(),
      ],
    ],
    'weight' => 1,
  ])
    ->save();
  $this
    ->drupalGet('node/1');
  $this
    ->assertSession()
    ->responseContains('Lat/Lng: 52/47');
  $this
    ->assertSession()
    ->responseContains('Title: My home');
}