aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/db/DatabaseTest.php
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2016-09-16 11:32:23 -0700
committerAaron Schulz <aschulz@wikimedia.org>2016-09-17 02:31:13 +0000
commit32c7a9bf46b8ba8d81ed534ecb9bba29c4e50610 (patch)
treefe994f363a939085f9df1f95fd1a502565399791 /tests/phpunit/includes/db/DatabaseTest.php
parent0a806b75f1450646bf54c36567e4085968ca0829 (diff)
downloadmediawikicore-32c7a9bf46b8ba8d81ed534ecb9bba29c4e50610.tar.gz
mediawikicore-32c7a9bf46b8ba8d81ed534ecb9bba29c4e50610.zip
Make LoadBalancer domain handling more robust
* Cleanup setDomainPrefix() methods to handle existing LBs/DBs. * This also makes it set just the prefix as the prefix rather than as the whole domain. * Fix regression from 789a54a5f1 where "read" mode of tablePrefix()/dbSchema() still set the field. * Make getConnectionRef() always have the domain set. * Add a check in openConnection() for explicit local connections, treating $domain as false and avoiding openForeignConnection(). Bug: T145840 Change-Id: Idf392bd9992a215c4fa3bddf275562f3916596aa
Diffstat (limited to 'tests/phpunit/includes/db/DatabaseTest.php')
-rw-r--r--tests/phpunit/includes/db/DatabaseTest.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/phpunit/includes/db/DatabaseTest.php b/tests/phpunit/includes/db/DatabaseTest.php
index d4be6e4fa0f3..134caf4abb1e 100644
--- a/tests/phpunit/includes/db/DatabaseTest.php
+++ b/tests/phpunit/includes/db/DatabaseTest.php
@@ -427,4 +427,26 @@ class DatabaseTest extends MediaWikiTestCase {
$this->assertEquals( $origSsl, $db->getFlag( DBO_SSL ) );
$this->assertEquals( $origTrx, $db->getFlag( DBO_TRX ) );
}
+
+ /**
+ * @covers DatabaseBase::tablePrefix()
+ * @covers DatabaseBase::dbSchema()
+ */
+ public function testMutators() {
+ $old = $this->db->tablePrefix();
+ $this->assertType( 'string', $old, 'Prefix is string' );
+ $this->assertEquals( $old, $this->db->tablePrefix(), "Prefix unchanged" );
+ $this->assertEquals( $old, $this->db->tablePrefix( 'xxx' ) );
+ $this->assertEquals( 'xxx', $this->db->tablePrefix(), "Prefix set" );
+ $this->db->tablePrefix( $old );
+ $this->assertNotEquals( 'xxx', $this->db->tablePrefix() );
+
+ $old = $this->db->dbSchema();
+ $this->assertType( 'string', $old, 'Schema is string' );
+ $this->assertEquals( $old, $this->db->dbSchema(), "Schema unchanged" );
+ $this->assertEquals( $old, $this->db->dbSchema( 'xxx' ) );
+ $this->assertEquals( 'xxx', $this->db->dbSchema(), "Schema set" );
+ $this->db->dbSchema( $old );
+ $this->assertNotEquals( 'xxx', $this->db->dbSchema() );
+ }
}