function KernelTestBaseTest::testSetUp

Same name in this branch
  1. 8.9.x core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
  2. 10 core/modules/pgsql/tests/src/Kernel/pgsql/KernelTestBaseTest.php \Drupal\Tests\pgsql\Kernel\pgsql\KernelTestBaseTest::testSetUp()
  3. 10 core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()
  4. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/KernelTestBaseTest.php \Drupal\Tests\pgsql\Kernel\pgsql\KernelTestBaseTest::testSetUp()
  5. 11.x core/tests/Drupal/KernelTests/KernelTestBaseTest.php \Drupal\KernelTests\KernelTestBaseTest::testSetUp()

Tests expected behavior of setUp().

File

core/modules/simpletest/src/Tests/KernelTestBaseTest.php, line 53

Class

KernelTestBaseTest
Tests KernelTestBase functionality.

Namespace

Drupal\simpletest\Tests

Code

public function testSetUp() {
    $modules = [
        '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(Database::getConnection()->schema()
        ->tableExists($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());
    }
}

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