You are here

protected function GeolocationCommonMapAjaxJavascriptTest::setUp in Geolocation Field 8

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

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/GeolocationCommonMapAjaxJavascriptTest.php, line 40

Class

GeolocationCommonMapAjaxJavascriptTest
Tests the common map style AJAX JavaScript 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();
  $this->container
    ->get('views.views_data')
    ->clear();
  ViewTestData::createTestViews(get_class($this), [
    'geolocation_test_views',
  ]);
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('node');
  $entity_test_storage
    ->create([
    'id' => 1,
    'title' => 'Location 1',
    'body' => 'location 1 test body',
    'type' => 'article',
    'field_geolocation' => [
      'lat' => 52,
      'lng' => 47,
    ],
  ])
    ->save();
  $entity_test_storage
    ->create([
    'id' => 2,
    'title' => 'Location 2',
    'body' => 'location 2 test body',
    'type' => 'article',
    'field_geolocation' => [
      'lat' => 53,
      'lng' => 48,
    ],
  ])
    ->save();
  $entity_test_storage
    ->create([
    'id' => 3,
    'title' => 'Location 3',
    'body' => 'location 3 test body',
    'type' => 'article',
    'field_geolocation' => [
      'lat' => 54,
      'lng' => 49,
    ],
  ])
    ->save();
}