mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-18 02:40:50 +00:00
713f60aaa5
Use mocks when possible, and add the test to the Database group otherwise. Also rename 2 test files to avoid a PHPUnit deprecation of file name not matching class name. Change-Id: I16b2392daf01f63511c82b4ed0e67a38e35ddbe1
38 lines
930 B
PHP
38 lines
930 B
PHP
<?php
|
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
|
use Wikimedia\Rdbms\ILoadBalancer;
|
|
|
|
/**
|
|
* @covers \MWEchoDbFactory
|
|
* @group Database
|
|
*/
|
|
class MWEchoDbFactoryTest extends MediaWikiIntegrationTestCase {
|
|
|
|
public function testNewFromDefault() {
|
|
$db = MWEchoDbFactory::newFromDefault();
|
|
$this->assertInstanceOf( MWEchoDbFactory::class, $db );
|
|
|
|
return $db;
|
|
}
|
|
|
|
/**
|
|
* @depends testNewFromDefault
|
|
*/
|
|
public function testGetEchoDb( MWEchoDbFactory $db ) {
|
|
$this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_PRIMARY ) );
|
|
$this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_REPLICA ) );
|
|
}
|
|
|
|
/**
|
|
* @depends testNewFromDefault
|
|
*/
|
|
public function testGetLB( MWEchoDbFactory $db ) {
|
|
$reflection = new ReflectionClass( MWEchoDbFactory::class );
|
|
$method = $reflection->getMethod( 'getLB' );
|
|
$method->setAccessible( true );
|
|
$this->assertInstanceOf( ILoadBalancer::class, $method->invoke( $db ) );
|
|
}
|
|
|
|
}
|