class DriverSpecificKernelTestBase
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase
- 10 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase
Base class for driver specific kernel tests.
Driver specific tests should be created in the \Drupal\Tests\mymodule\Kernel\mydriver namespace, and their execution will only occur when the database driver of the SUT is provided by 'mymodule' and named 'mydriver'.
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of DriverSpecificKernelTestBase
4 files declare their use of DriverSpecificKernelTestBase
- DatabaseExceptionWrapperTest.php in core/
modules/ sqlite/ tests/ src/ Kernel/ sqlite/ DatabaseExceptionWrapperTest.php - DatabaseExceptionWrapperTest.php in core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ DatabaseExceptionWrapperTest.php - DatabaseExceptionWrapperTest.php in core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ DatabaseExceptionWrapperTest.php - PrefixInfoTest.php in core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ PrefixInfoTest.php
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificKernelTestBase.php, line 18
Namespace
Drupal\KernelTests\Core\DatabaseView source
abstract class DriverSpecificKernelTestBase extends KernelTestBase {
/**
* The database connection for testing.
*/
protected $connection;
/**
* {@inheritdoc}
*/
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.