protected function ViewUnitTestBase::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.

3 calls to ViewUnitTestBase::setUpFixtures()
RelationshipJoinTestBase::setUpFixtures in drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/RelationshipJoinTestBase.php
Overrides \Drupal\views\Tests\ViewUnitTestBase::setUpFixtures().
ViewExecutableTest::setUpFixtures in drupal/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
Sets up the configuration and schema of views and views_test_data modules.
ViewUnitTestBase::setUp in drupal/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php
Sets up Drupal unit test environment.
2 methods override ViewUnitTestBase::setUpFixtures()
RelationshipJoinTestBase::setUpFixtures in drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/RelationshipJoinTestBase.php
Overrides \Drupal\views\Tests\ViewUnitTestBase::setUpFixtures().
ViewExecutableTest::setUpFixtures in drupal/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
Sets up the configuration and schema of views and views_test_data modules.

File

drupal/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php, line 46
Contains \Drupal\views\Tests\ViewUnitTestBase.

Class

ViewUnitTestBase
Defines a base class for Views unit testing.

Namespace

Drupal\views\Tests

Code

protected function setUpFixtures() {

  // Define the schema and views data variable before enabling the test module.
  \Drupal::state()
    ->set('views_test_data_schema', $this
    ->schemaDefinition());
  \Drupal::state()
    ->set('views_test_data_views_data', $this
    ->viewsData());
  $this
    ->installConfig(array(
    'views',
    'views_test_config',
    'views_test_data',
  ));
  foreach ($this
    ->schemaDefinition() as $table => $schema) {
    $this
      ->installSchema('views_test_data', $table);
  }

  // Load the test dataset.
  $data_set = $this
    ->dataSet();
  $query = db_insert('views_test_data')
    ->fields(array_keys($data_set[0]));
  foreach ($data_set as $record) {
    $query
      ->values($record);
  }
  $query
    ->execute();

  // Tests implementing ViewUnitTestBase depend on the theme system being
  // properly configured.
  $this
    ->installConfig(array(
    'system',
  ));
  ViewTestData::importTestViews(get_class($this), array(
    'views_test_config',
  ));
}