You are here

function ConnectionTest::testConnectionRoutingOverride in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Database/ConnectionTest.php \Drupal\system\Tests\Database\ConnectionTest::testConnectionRoutingOverride()

Tests that connections return appropriate connection objects.

File

core/modules/system/src/Tests/Database/ConnectionTest.php, line 57
Contains \Drupal\system\Tests\Database\ConnectionTest.

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\system\Tests\Database

Code

function testConnectionRoutingOverride() {

  // Clone the primary credentials to a replica connection.
  // Note this will result in two independent connection objects that happen
  // to point to the same place.
  $connection_info = Database::getConnectionInfo('default');
  Database::addConnectionInfo('default', 'replica', $connection_info['default']);
  Database::ignoreTarget('default', 'replica');
  $db1 = Database::getConnection('default', 'default');
  $db2 = Database::getConnection('replica', 'default');
  $this
    ->assertIdentical($db1, $db2, 'Both targets refer to the same connection.');
}