You are here

function KernelTestBaseTest::testSetUp in Zircon Profile 8.0

Same name in this branch
  1. 8.0 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
  2. 8.0 core/modules/simpletest/src/Tests/KernelTestBaseTest.php \Drupal\simpletest\Tests\KernelTestBaseTest::testSetUp()
Same name and namespace in other branches
  1. 8 core/modules/simpletest/src/Tests/KernelTestBaseTest.php \Drupal\simpletest\Tests\KernelTestBaseTest::testSetUp()

Tests expected behavior of setUp().

File

core/modules/simpletest/src/Tests/KernelTestBaseTest.php, line 55
Contains \Drupal\simpletest\Tests\KernelTestBaseTest.

Class

KernelTestBaseTest
Tests KernelTestBase functionality.

Namespace

Drupal\simpletest\Tests

Code

function testSetUp() {
  $modules = array(
    'entity_test',
  );
  $table = 'entity_test';

  // Verify that specified $modules have been loaded.
  $this
    ->assertTrue(function_exists('entity_test_entity_bundle_info'), 'entity_test.module was loaded.');

  // Verify that there is a fixed module list.
  $this
    ->assertIdentical(array_keys(\Drupal::moduleHandler()
    ->getModuleList()), $modules);
  $this
    ->assertIdentical(\Drupal::moduleHandler()
    ->getImplementations('entity_bundle_info'), [
    'entity_test',
  ]);
  $this
    ->assertIdentical(\Drupal::moduleHandler()
    ->getImplementations('entity_type_alter'), [
    'entity_test',
  ]);

  // Verify that no modules have been installed.
  $this
    ->assertFalse(db_table_exists($table), "'{$table}' database table not found.");

  // Verify that the settings.testing.php got taken into account.
  $this
    ->assertTrue(function_exists('simpletest_test_stub_settings_function'));

  // Ensure that the database tasks have been run during set up. Neither MySQL
  // nor SQLite make changes that are testable.
  $database = $this->container
    ->get('database');
  if ($database
    ->driver() == 'pgsql') {
    $this
      ->assertEqual('on', $database
      ->query("SHOW standard_conforming_strings")
      ->fetchField());
    $this
      ->assertEqual('escape', $database
      ->query("SHOW bytea_output")
      ->fetchField());
  }
}