function FieldEntityTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Entity/FieldEntityTest.php \Drupal\Tests\views\Functional\Entity\FieldEntityTest::setUp()
  2. 8.9.x core/modules/views/tests/src/Functional/Entity/FieldEntityTest.php \Drupal\Tests\views\Functional\Entity\FieldEntityTest::setUp()
  3. 10 core/modules/views/tests/src/Functional/Entity/FieldEntityTest.php \Drupal\Tests\views\Functional\Entity\FieldEntityTest::setUp()

Overrides ViewTestBase::setUp

File

core/modules/views/tests/src/Functional/Entity/FieldEntityTest.php, line 53

Class

FieldEntityTest
Tests the field plugin base integration with the entity system.

Namespace

Drupal\Tests\views\Functional\Entity

Code

protected function setUp($import_test_views = TRUE, $modules = [
    'views_test_config',
]) : void {
    parent::setUp(FALSE, $modules);
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    $this->addDefaultCommentField('node', 'page');
    // Add an entity reference field for the test_field_get_entity_null view.
    FieldStorageConfig::create([
        'field_name' => 'field_test_reference',
        'type' => 'entity_reference',
        'entity_type' => 'node',
        'cardinality' => 1,
        'settings' => [
            'target_type' => 'node',
        ],
    ])->save();
    FieldConfig::create([
        'field_name' => 'field_test_reference',
        'entity_type' => 'node',
        'bundle' => 'page',
        'label' => 'field_test_reference',
        'settings' => [
            'handler' => 'default',
            'handler_settings' => [
                'target_bundles' => [
                    'page' => 'page',
                ],
            ],
        ],
    ])->save();
    ViewTestData::createTestViews(static::class, $modules);
}

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