function FieldRenderedEntityTest::setUpFixtures

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::setUpFixtures()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::setUpFixtures()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php \Drupal\Tests\views\Kernel\Handler\FieldRenderedEntityTest::setUpFixtures()

Overrides ViewsKernelTestBase::setUpFixtures

File

core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php, line 46

Class

FieldRenderedEntityTest
Tests the core Drupal\views\Plugin\views\field\RenderedEntity handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

protected function setUpFixtures() {
    $this->installEntitySchema('user');
    $this->installEntitySchema('entity_test');
    $this->installConfig([
        'entity_test',
    ]);
    EntityViewMode::create([
        'id' => 'entity_test.foobar',
        'targetEntityType' => 'entity_test',
        'status' => TRUE,
        'enabled' => TRUE,
        'label' => 'My view mode',
    ])->save();
    $display = EntityViewDisplay::create([
        'targetEntityType' => 'entity_test',
        'bundle' => 'entity_test',
        'mode' => 'foobar',
        'label' => 'My view mode',
        'status' => TRUE,
    ]);
    $display->save();
    $field_storage = FieldStorageConfig::create([
        'field_name' => 'test_field',
        'entity_type' => 'entity_test',
        'type' => 'string',
    ]);
    $field_storage->save();
    $field_config = FieldConfig::create([
        'field_name' => 'test_field',
        'entity_type' => 'entity_test',
        'bundle' => 'entity_test',
    ]);
    $field_config->save();
    // Create some test entities.
    for ($i = 1; $i <= 3; $i++) {
        EntityTest::create([
            'name' => "Article title {$i}",
            'test_field' => "Test {$i}",
        ])->save();
    }
    $this->user = User::create([
        'name' => 'test user',
    ]);
    $this->user
        ->save();
    parent::setUpFixtures();
}

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