Issue #1925658 by gielfeldt, mitron: Fixed Use of slaves breaks site.

8.0.x
webchick 2013-02-26 18:05:49 -05:00
parent 4001ef85b2
commit 72558ac865
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<?php
/**
* Definition of Drupal\system\Tests\System\SystemInitTest.
*/
namespace Drupal\system\Tests\System;
use Drupal\Core\Database\Database;
use \Drupal\simpletest\UnitTestBase;
use \Symfony\Component\HttpFoundation\Request;
/**
* Tests system_init().
*/
class SystemInitTest extends UnitTestBase {
public static function getInfo() {
return array(
'name' => 'System Init',
'description' => 'Tests the system_init function in system.module.',
'group' => 'System',
);
}
/**
* Tests that system_init properly ignores slaves when requested.
*/
function testSystemInitIgnoresSlaves() {
// Clone the master credentials to a slave 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', 'slave', $connection_info['default']);
db_ignore_slave();
system_init();
$db1 = Database::getConnection('default', 'default');
$db2 = Database::getConnection('slave', 'default');
$this->assertIdentical($db1, $db2, 'System Init ignores slaves when requested.');
}
}

View File

@ -5,6 +5,7 @@
* Configuration system that lets administrators modify the workings of the site.
*/
use Drupal\Core\Database\Database;
use Drupal\Core\Utility\ModuleInfo;
use Drupal\Core\TypedData\Primitive;
use Drupal\system\Plugin\block\block\SystemMenuBlock;