You are here

protected function ViewsDataTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/options/tests/src/Kernel/Views/ViewsDataTest.php \Drupal\Tests\options\Kernel\Views\ViewsDataTest::setUp()

Parameters

bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.

Overrides OptionsTestBase::setUp

File

core/modules/options/tests/src/Kernel/Views/ViewsDataTest.php, line 35

Class

ViewsDataTest
Test to ensure views data is properly created for the Options module.

Namespace

Drupal\Tests\options\Kernel\Views

Code

protected function setUp($import_test_views = TRUE) : void {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test');
  $field_name = 'test_options';
  $this->fieldStorage = FieldStorageConfig::create([
    'field_name' => $field_name,
    'entity_type' => 'entity_test',
    'type' => 'list_string',
    'cardinality' => 1,
    'settings' => [
      'allowed_values_function' => 'options_test_dynamic_values_callback',
    ],
  ]);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_name' => $field_name,
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
    'required' => TRUE,
  ])
    ->save();
}