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
|
|
|
/**
|
2019-10-23 10:23:09 +00:00
|
|
|
* @covers \MWEchoDbFactory
|
2018-01-24 00:31:53 +00:00
|
|
|
*/
|
2021-10-11 22:42:10 +00:00
|
|
|
class MWEchoDbFactoryTest extends MediaWikiIntegrationTestCase {
|
2014-07-18 03:58:21 +00:00
|
|
|
|
|
|
|
public function testNewFromDefault() {
|
|
|
|
$db = MWEchoDbFactory::newFromDefault();
|
2019-02-19 10:35:54 +00:00
|
|
|
$this->assertInstanceOf( MWEchoDbFactory::class, $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 ) {
|
2021-05-03 07:28:02 +00:00
|
|
|
$this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_PRIMARY ) );
|
2017-12-21 19:40:37 +00:00
|
|
|
$this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_REPLICA ) );
|
2014-07-18 03:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testNewFromDefault
|
|
|
|
*/
|
|
|
|
public function testGetLB( MWEchoDbFactory $db ) {
|
2019-02-19 10:35:54 +00:00
|
|
|
$reflection = new ReflectionClass( MWEchoDbFactory::class );
|
2014-07-18 03:58:21 +00:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
|
|
|
}
|