Debian Codegraph @

extensions/Echo/tests/phpunit/DbFactoryTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Notifications\Test;
4
5 use MediaWiki\Extension\Notifications\DbFactory;
6 use MediaWikiIntegrationTestCase;
7 use ReflectionClass;
8 use Wikimedia\Rdbms\IDatabase;
9 use Wikimedia\Rdbms\ILoadBalancer;
10
11 /**
12 * @covers \MediaWiki\Extension\Notifications\DbFactory
13 * @group Database
14 */
15 class DbFactoryTest extends MediaWikiIntegrationTestCase {
16
17 public function testNewFromDefault() {
18 $db = DbFactory::newFromDefault();
19 $this->assertInstanceOf( DbFactory::class, $db );
20
21 return $db;
22 }
23
24 /**
25 * @depends testNewFromDefault
26 */
27 public function testGetEchoDb( DbFactory $db ) {
28 $this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_PRIMARY ) );
29 $this->assertInstanceOf( IDatabase::class, $db->getEchoDb( DB_REPLICA ) );
30 }
31
32 /**
33 * @depends testNewFromDefault
34 */
35 public function testGetLB( DbFactory $db ) {
36 $reflection = new ReflectionClass( DbFactory::class );
37 $method = $reflection->getMethod( 'getLB' );
38 $this->assertInstanceOf( ILoadBalancer::class, $method->invoke( $db ) );
39 }
40
41 }