function DriverSpecificKernelTestBase::setUp

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase::setUp()
  2. 11.x core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase::setUp()

Overrides KernelTestBase::setUp

3 calls to DriverSpecificKernelTestBase::setUp()
DriverSpecificConnectionUnitTestBase::setUp in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php
DriverSpecificDatabaseTestBase::setUp in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificDatabaseTestBase.php
DriverSpecificSchemaTestBase::setUp in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php
3 methods override DriverSpecificKernelTestBase::setUp()
DriverSpecificConnectionUnitTestBase::setUp in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php
DriverSpecificDatabaseTestBase::setUp in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificDatabaseTestBase.php
DriverSpecificSchemaTestBase::setUp in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php

File

core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php, line 28

Class

DriverSpecificKernelTestBase
Base class for driver specific kernel tests.

Namespace

Drupal\KernelTests\Core\Database

Code

protected function setUp() : void {
    parent::setUp();
    $this->connection = Database::getConnection();
    $running_provider = $this->connection
        ->getProvider();
    $running_driver = $this->connection
        ->driver();
    $test_class_parts = explode('\\', get_class($this));
    $expected_provider = $test_class_parts[2] ?? '';
    for ($i = 3; $i < count($test_class_parts); $i++) {
        if ($test_class_parts[$i] === 'Kernel') {
            $expected_driver = $test_class_parts[$i + 1] ?? '';
            break;
        }
    }
    if ($running_provider !== $expected_provider || $running_driver !== $expected_driver) {
        $this->markTestSkipped("This test only runs for the database driver '{$expected_driver}' provided by the '{$expected_provider}' module. Connected database driver is '{$running_driver}' provided by '{$running_provider}'.");
    }
}

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