class InstallerObjectTest
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php \Drupal\Tests\Core\Database\InstallerObjectTest
- 8.9.x core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php \Drupal\Tests\Core\Database\InstallerObjectTest
Tests the db_installer_object() function that is used during installation.
These tests run in isolation to prevent the autoloader additions from affecting other tests.
@covers ::db_installer_object
@runTestsInSeparateProcesses @preserveGlobalState disabled
@group Database @group legacy
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait
- class \Drupal\Tests\Core\Database\InstallerObjectTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of InstallerObjectTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ InstallerObjectTest.php, line 28
Namespace
Drupal\Tests\Core\DatabaseView source
class InstallerObjectTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
require_once __DIR__ . '/../../../../../includes/install.inc';
$additional_class_loader = new ClassLoader();
$additional_class_loader->addPsr4("Drupal\\Driver\\Database\\fake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/custom/fake");
$additional_class_loader->addPsr4("Drupal\\Core\\Database\\Driver\\CoreFake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/core/CoreFake");
$additional_class_loader->addPsr4("Drupal\\Driver\\Database\\CoreFake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/custom/CoreFake");
$additional_class_loader->addPsr4("Drupal\\driver_test\\Driver\\Database\\DrivertestMysql\\", __DIR__ . "/../../../../../../modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql");
$additional_class_loader->register(TRUE);
}
/**
* @dataProvider providerDbInstallerObject
*/
public function testDbInstallerObject($driver, $namespace, $expected_class_name) : void {
$this->expectDeprecation('db_installer_object() is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3256641');
$object = db_installer_object($driver, $namespace);
$this->assertEquals(get_class($object), $expected_class_name);
}
/**
* Data provider for testDbUrlToConnectionConversion().
*
* @return array
* Array of arrays with the following elements:
* - driver: The driver name.
* - namespace: The namespace providing the driver.
* - class: The fully qualified class name of the expected install task.
*/
public static function providerDbInstallerObject() {
return [
// A driver only in the core namespace.
[
'mysql',
"Drupal\\mysql\\Driver\\Database\\mysql",
MysqlInstallTasks::class,
],
// A driver only in the custom namespace.
// @phpstan-ignore-next-line
[
'fake',
"Drupal\\Driver\\Database\\fake",
FakeInstallTasks::class,
],
// A driver in both namespaces. The custom one takes precedence.
// @phpstan-ignore-next-line
[
'CoreFake',
"Drupal\\Driver\\Database\\CoreFake",
CustomCoreFakeInstallTasks::class,
],
// A driver from a module that has a different name as the driver.
[
'DrivertestMysql',
"Drupal\\driver_test\\Driver\\Database\\DrivertestMysql",
DriverTestMysqlInstallTasks::class,
],
];
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
InstallerObjectTest::providerDbInstallerObject | public static | function | Data provider for testDbUrlToConnectionConversion(). | |||
InstallerObjectTest::setUp | protected | function | Overrides UnitTestCase::setUp | |||
InstallerObjectTest::testDbInstallerObject | public | function | @dataProvider providerDbInstallerObject | |||
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |||
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |||
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |||
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |||
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |||
RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. | ||
UnitTestCase::$root | protected | property | The app root. | 1 | ||
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |||
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |||
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |||
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |||
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |||
UnitTestCase::setUpBeforeClass | public static | function | ||||
UnitTestCase::__get | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.