You are here

protected function GeolocationTokenFormatterTest::setUp in Geolocation Field 8.2

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

Overrides BrowserTestBase::setUp

File

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

Class

GeolocationTokenFormatterTest
Tests the Token Formatter functionality.

Namespace

Drupal\Tests\geolocation\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);

  // Add the geolocation field to the article content type.
  FieldStorageConfig::create([
    'field_name' => 'field_geolocation',
    'entity_type' => 'node',
    'type' => 'geolocation',
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_geolocation',
    'label' => 'Geolocation',
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();
  EntityFormDisplay::load('node.article.default')
    ->setComponent('field_geolocation', [
    'type' => 'geolocation_latlng',
  ])
    ->save();
  EntityViewDisplay::load('node.article.default')
    ->setComponent('field_geolocation', [
    'type' => 'geolocation_latlng',
    'weight' => 1,
  ])
    ->save();
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('node');
  $entity_test_storage
    ->create([
    'id' => 1,
    'title' => 'Test node 1',
    'body' => 'test test',
    'type' => 'article',
    'field_geolocation' => [
      'lat' => 52,
      'lng' => 47,
      'data' => [
        'title' => 'My home',
        // Not used, just to check interference with other values.
        'extraconfig' => 'myvalue',
      ],
    ],
  ])
    ->save();
}