function ViewsKernelTestBase::setUpFixtures

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

Sets up the configuration and schema of views and views_test_data modules.

Because the schema of views_test_data.module is dependent on the test using it, it cannot be enabled normally.

7 calls to ViewsKernelTestBase::setUpFixtures()
AreaEntityTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
Sets up the configuration and schema of views and views_test_data modules.
AreaOrderTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php
Sets up the configuration and schema of views and views_test_data modules.
FieldEntityLinkTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php
Sets up the configuration and schema of views and views_test_data modules.
FieldRenderedEntityTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php
Sets up the configuration and schema of views and views_test_data modules.
RowRenderCacheTest::setUpFixtures in core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php
Sets up the configuration and schema of views and views_test_data modules.

... See full list

6 methods override ViewsKernelTestBase::setUpFixtures()
AreaEntityTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
Sets up the configuration and schema of views and views_test_data modules.
AreaOrderTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/AreaOrderTest.php
Sets up the configuration and schema of views and views_test_data modules.
FieldEntityLinkTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/FieldEntityLinkTest.php
Sets up the configuration and schema of views and views_test_data modules.
FieldRenderedEntityTest::setUpFixtures in core/modules/views/tests/src/Kernel/Handler/FieldRenderedEntityTest.php
Sets up the configuration and schema of views and views_test_data modules.
RowRenderCacheTest::setUpFixtures in core/modules/views/tests/src/Kernel/Plugin/RowRenderCacheTest.php
Sets up the configuration and schema of views and views_test_data modules.

... See full list

File

core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php, line 65

Class

ViewsKernelTestBase
Defines a base class for Views kernel testing.

Namespace

Drupal\Tests\views\Kernel

Code

protected function setUpFixtures() {
    // First install the system module. Many Views have Page displays have menu
    // links, and for those to work, the system menus must already be present.
    $this->installConfig([
        'system',
    ]);
    
    /** @var \Drupal\Core\State\StateInterface $state */
    $state = $this->container
        ->get('state');
    // Define the schema and views data variable before enabling the test module.
    $state->set('views_test_data_schema', $this->schemaDefinition());
    $state->set('views_test_data_views_data', $this->viewsData());
    $this->container
        ->get('views.views_data')
        ->clear();
    $this->installConfig([
        'views',
        'views_test_config',
        'views_test_data',
    ]);
    foreach ($this->schemaDefinition() as $table => $schema) {
        $this->installSchema('views_test_data', $table);
    }
    $this->container
        ->get('router.builder')
        ->rebuild();
    // Load the test dataset.
    $data_set = $this->dataSet();
    $query = Database::getConnection()->insert('views_test_data')
        ->fields(array_keys($data_set[0]));
    foreach ($data_set as $record) {
        $query->values($record);
    }
    $query->execute();
}

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