You are here

protected function RangeViewsTestBase::setUp in Range 8

Overrides ViewTestBase::setUp

2 calls to RangeViewsTestBase::setUp()
RangeViewsArgumentTest::setUp in tests/src/Functional/Views/RangeViewsArgumentTest.php
RangeViewsFilterTest::setUp in tests/src/Functional/Views/RangeViewsFilterTest.php
2 methods override RangeViewsTestBase::setUp()
RangeViewsArgumentTest::setUp in tests/src/Functional/Views/RangeViewsArgumentTest.php
RangeViewsFilterTest::setUp in tests/src/Functional/Views/RangeViewsFilterTest.php

File

tests/src/Functional/Views/RangeViewsTestBase.php, line 59

Class

RangeViewsTestBase
Base class for testing range handlers.

Namespace

Drupal\Tests\range\Functional\Views

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp();

  // Add a date field to page nodes.
  $node_type = NodeType::create([
    'type' => $this->bundle,
    'name' => $this->bundle,
  ]);
  $node_type
    ->save();
  $fieldStorage = FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => $this->entityTypeId,
    'type' => 'range_integer',
  ]);
  $fieldStorage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $fieldStorage,
    'bundle' => $this->bundle,
    'required' => TRUE,
  ]);
  $field
    ->save();

  // Views needs to be aware of the new field.
  $this->container
    ->get('views.views_data')
    ->clear();

  // Set column map.
  $this->map = [
    'nid' => 'nid',
  ];

  // Load test views.
  ViewTestData::createTestViews(get_class($this), [
    'range_test',
  ]);
}