2014-07-18 03:58:21 +00:00
|
|
|
<?php
|
|
|
|
|
2017-12-21 19:40:37 +00:00
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
|
|
|
use Wikimedia\Rdbms\ILoadBalancer;
|
|
|
|
|
2018-01-24 00:31:53 +00:00
|
|
|
/**
|
|
|
|
* @covers MWEchoDbFactory
|
|
|
|
*/
|
2014-07-18 03:58:21 +00:00
|
|
|
class MWEchoDbFactoryTest extends MediaWikiTestCase {
|
|
|
|
|
|
|
|
public function testNewFromDefault() {
|
|
|
|
$db = MWEchoDbFactory::newFromDefault();
|
|
|
|
$this->assertInstanceOf( 'MWEchoDbFactory', $db );
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2014-07-18 03:58:21 +00:00
|
|
|
return $db;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testNewFromDefault
|
|
|
|
*/
|
|
|
|
public function testGetEchoDb( MWEchoDbFactory $db ) {
|
2017-12-21 19:40:37 +00:00
|
|
|
$this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_MASTER ) );
|
|
|
|
$this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_REPLICA ) );
|
2014-07-18 03:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testNewFromDefault
|
|
|
|
*/
|
|
|
|
public function testGetLB( MWEchoDbFactory $db ) {
|
|
|
|
$reflection = new ReflectionClass( 'MWEchoDbFactory' );
|
|
|
|
$method = $reflection->getMethod( 'getLB' );
|
|
|
|
$method->setAccessible( true );
|
2017-12-21 19:40:37 +00:00
|
|
|
$this->assertInstanceOf( ILoadBalancer::class, $method->invoke( $db ) );
|
2014-07-18 03:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|