function ViewsDataTest::setUp

Same name in this branch
  1. 11.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::setUp()
Same name and namespace in other branches
  1. 9 core/modules/options/tests/src/Kernel/Views/ViewsDataTest.php \Drupal\Tests\options\Kernel\Views\ViewsDataTest::setUp()
  2. 9 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::setUp()
  3. 8.9.x core/modules/options/tests/src/Kernel/Views/ViewsDataTest.php \Drupal\Tests\options\Kernel\Views\ViewsDataTest::setUp()
  4. 8.9.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::setUp()
  5. 10 core/modules/options/tests/src/Kernel/Views/ViewsDataTest.php \Drupal\Tests\options\Kernel\Views\ViewsDataTest::setUp()
  6. 10 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest::setUp()

Overrides OptionsTestBase::setUp

File

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

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.