function SqlBaseTest::testBrokenConnection
Same name in other branches
- 10 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest::testBrokenConnection()
Tests the exception when a connection is defined but not available.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ SqlBaseTest.php, line 131
Class
- SqlBaseTest
- Tests the functionality of SqlBase.
Namespace
Drupal\Tests\migrate\KernelCode
public function testBrokenConnection() : void {
if (Database::getConnection()->driver() === 'sqlite') {
$this->markTestSkipped('Not compatible with sqlite');
}
$sql_base = new TestSqlBase([], $this->migration);
$target = 'test_state_db_target2';
$key = 'test_state_migrate_connection2';
$database = Database::getConnectionInfo('default')['default'];
$database['database'] = 'godot';
$config = [
'target' => $target,
'key' => $key,
'database' => $database,
];
$database_state_key = 'migrate_sql_base_test2';
\Drupal::state()->set($database_state_key, $config);
$sql_base->setConfiguration([
'database_state_key' => $database_state_key,
]);
// Call checkRequirements(): it will call getDatabase() and convert the
// exception to a RequirementsException.
$this->expectException(RequirementsException::class);
$this->expectExceptionMessage('No database connection available for source plugin sql_base');
$sql_base->checkRequirements();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.