2014-07-18 03:58:21 +00:00
|
|
|
<?php
|
|
|
|
|
2024-02-22 15:31:00 +00:00
|
|
|
namespace MediaWiki\Extension\Notifications\Test;
|
|
|
|
|
2022-11-12 07:19:00 +00:00
|
|
|
use MediaWiki\Extension\Notifications\DbFactory;
|
2024-02-22 15:31:00 +00:00
|
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
use ReflectionClass;
|
2017-12-21 19:40:37 +00:00
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
|
|
|
use Wikimedia\Rdbms\ILoadBalancer;
|
|
|
|
|
2018-01-24 00:31:53 +00:00
|
|
|
/**
|
2022-11-12 07:19:00 +00:00
|
|
|
* @covers \MediaWiki\Extension\Notifications\DbFactory
|
2023-08-04 00:31:24 +00:00
|
|
|
* @group Database
|
2018-01-24 00:31:53 +00:00
|
|
|
*/
|
2022-11-12 07:19:00 +00:00
|
|
|
class DbFactoryTest extends MediaWikiIntegrationTestCase {
|
2014-07-18 03:58:21 +00:00
|
|
|
|
|
|
|
public function testNewFromDefault() {
|
2022-11-12 07:19:00 +00:00
|
|
|
$db = DbFactory::newFromDefault();
|
|
|
|
$this->assertInstanceOf( DbFactory::class, $db );
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2014-07-18 03:58:21 +00:00
|
|
|
return $db;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testNewFromDefault
|
|
|
|
*/
|
2022-11-12 07:19:00 +00:00
|
|
|
public function testGetEchoDb( DbFactory $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
|
|
|
|
*/
|
2022-11-12 07:19:00 +00:00
|
|
|
public function testGetLB( DbFactory $db ) {
|
|
|
|
$reflection = new ReflectionClass( DbFactory::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
|
|
|
}
|
|
|
|
|
|
|
|
}
|