InstallerObjectTest.php in Drupal 8
File
core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php
View source
<?php
namespace Drupal\Tests\Core\Database;
use Composer\Autoload\ClassLoader;
use Drupal\Core\Database\Driver\mysql\Install\Tasks as MysqlInstallTasks;
use Drupal\Driver\Database\fake\Install\Tasks as FakeInstallTasks;
use Drupal\Driver\Database\corefake\Install\Tasks as CustomCoreFakeInstallTasks;
use Drupal\driver_test\Driver\Database\DrivertestMysql\Install\Tasks as DriverTestMysqlInstallTasks;
use Drupal\Tests\UnitTestCase;
class InstallerObjectTest extends UnitTestCase {
protected function setUp() {
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);
}
public function testDbInstallerObject($driver, $namespace, $expected_class_name) {
$object = db_installer_object($driver, $namespace);
$this
->assertEquals(get_class($object), $expected_class_name);
}
public function providerDbInstallerObject() {
return [
[
'mysql',
NULL,
MysqlInstallTasks::class,
],
[
'fake',
"Drupal\\Driver\\Database\\fake",
FakeInstallTasks::class,
],
[
'corefake',
"Drupal\\Driver\\Database\\corefake",
CustomCoreFakeInstallTasks::class,
],
[
'DrivertestMysql',
"Drupal\\driver_test\\Driver\\Database\\DrivertestMysql",
DriverTestMysqlInstallTasks::class,
],
];
}
}