- // Check the default values.
- $sql_base->setConfiguration([]);
- $this->assertIdentical($sql_base->getDatabase()->getTarget(), 'default');
- $this->assertIdentical($sql_base->getDatabase()->getKey(), 'migrate');
+ // Verify that falling back to the default 'migrate' connection (defined in
+ // the base class) works.
+ $this->assertSame($sql_base->getDatabase()->getTarget(), 'default');
+ $this->assertSame($sql_base->getDatabase()->getKey(), 'migrate');
+
+ // Verify the fallback state key overrides the 'migrate' connection.
+ $target = 'test_fallback_target';
+ $key = 'test_fallback_key';
+ $config = ['target' => $target, 'key' => $key];
+ $database_state_key = 'test_fallback_state';
+ \Drupal::state()->set($database_state_key, $config);
+ \Drupal::state()->set('migrate.fallback_state_key', $database_state_key);
+ // Create a test connection using the default database configuration.
+ Database::addConnectionInfo($key, $target, Database::getConnectionInfo('default')['default']);
+ $this->assertSame($sql_base->getDatabase()->getTarget(), $target);
+ $this->assertSame($sql_base->getDatabase()->getKey(), $key);