Skip to content
Snippets Groups Projects
Commit f19d83c4 authored by Angie Byron's avatar Angie Byron
Browse files

#302300 follow-up by Crell: Fixes to database connection tests.

parent 2cb811ac
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -839,7 +839,7 @@ final public static function getConnectionInfo($key = 'default') { ...@@ -839,7 +839,7 @@ final public static function getConnectionInfo($key = 'default') {
final protected static function openConnection($key, $target) { final protected static function openConnection($key, $target) {
global $db_prefix; global $db_prefix;
if (empty(self::$connectionInfo)) { if (empty(self::$databaseInfo)) {
self::parseConnectionInfo(); self::parseConnectionInfo();
} }
try { try {
......
...@@ -127,13 +127,15 @@ class DatabaseConnectionTestCase extends DatabaseTestCase { ...@@ -127,13 +127,15 @@ class DatabaseConnectionTestCase extends DatabaseTestCase {
// Clone the master credentials to a slave connection. // Clone the master credentials to a slave connection.
// Note this will result in two independent connection objects that happen // Note this will result in two independent connection objects that happen
// to point to the same place. // to point to the same place.
$connection_info = Database::getConnectionInfo(); $connection_info = Database::getConnectionInfo('default');
Database::addConnectionInfo('default', 'slave', $connection_info['default']['default']); Database::addConnectionInfo('default', 'slave', $connection_info['default']);
$db1 = Database::getConnection('default', 'default'); $db1 = Database::getConnection('default', 'default');
$db2 = Database::getConnection('default', 'slave'); $db2 = Database::getConnection('default', 'slave');
$this->assertFalse($db1 === $db2, t('Each target refers to a different connection.')); $this->assertNotNull($db1, t('default connection is a real connection object.'));
$this->assertNotNull($db2, t('slave connection is a real connection object.'));
$this->assertNotIdentical($db1, $db2, t('Each target refers to a different connection.'));
} }
/** /**
...@@ -152,7 +154,7 @@ class DatabaseConnectionTestCase extends DatabaseTestCase { ...@@ -152,7 +154,7 @@ class DatabaseConnectionTestCase extends DatabaseTestCase {
$db1 = Database::getConnection('default', 'default'); $db1 = Database::getConnection('default', 'default');
$db2 = Database::getConnection('default', 'slave'); $db2 = Database::getConnection('default', 'slave');
$this->assertTrue($db1 === $db2, t('Both targets refer to the same connection.')); $this->assertIdentical($db1, $db2, t('Both targets refer to the same connection.'));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment