Merge "Add checkDependencies.php"
[lhc/web/wiklou.git] / tests / phpunit / includes / db / LBFactoryTest.php
index 02c25e7..f7007e7 100644 (file)
@@ -23,7 +23,6 @@
  * @copyright © 2013 Wikimedia Foundation Inc.
  */
 
-use Wikimedia\Rdbms\Database;
 use Wikimedia\Rdbms\IDatabase;
 use Wikimedia\Rdbms\IMaintainableDatabase;
 use Wikimedia\Rdbms\LBFactory;
@@ -31,7 +30,6 @@ use Wikimedia\Rdbms\LBFactorySimple;
 use Wikimedia\Rdbms\LBFactoryMulti;
 use Wikimedia\Rdbms\LoadBalancer;
 use Wikimedia\Rdbms\ChronologyProtector;
-use Wikimedia\Rdbms\DatabaseMysqli;
 use Wikimedia\Rdbms\MySQLMasterPos;
 use Wikimedia\Rdbms\DatabaseDomain;
 
@@ -48,7 +46,7 @@ class LBFactoryTest extends MediaWikiTestCase {
         * @dataProvider getLBFactoryClassProvider
         */
        public function testGetLBFactoryClass( $expected, $deprecated ) {
-               $mockDB = $this->getMockBuilder( DatabaseMysqli::class )
+               $mockDB = $this->getMockBuilder( IDatabase::class )
                        ->disableOriginalConstructor()
                        ->getMock();
 
@@ -292,7 +290,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                $m2Pos = new MySQLMasterPos( 'db1064-bin.002400/794074907', $now );
 
                // Master DB 1
-               $mockDB1 = $this->getMockBuilder( DatabaseMysqli::class )
+               $mockDB1 = $this->getMockBuilder( IDatabase::class )
                        ->disableOriginalConstructor()
                        ->getMock();
                $mockDB1->method( 'writesOrCallbacksPending' )->willReturn( true );
@@ -317,7 +315,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                $lb1->method( 'getMasterPos' )->willReturn( $m1Pos );
                $lb1->method( 'getServerName' )->with( 0 )->willReturn( 'master1' );
                // Master DB 2
-               $mockDB2 = $this->getMockBuilder( DatabaseMysqli::class )
+               $mockDB2 = $this->getMockBuilder( IDatabase::class )
                        ->disableOriginalConstructor()
                        ->getMock();
                $mockDB2->method( 'writesOrCallbacksPending' )->willReturn( true );
@@ -348,7 +346,8 @@ class LBFactoryTest extends MediaWikiTestCase {
                        [
                                'ip' => '127.0.0.1',
                                'agent' => "Totally-Not-FireFox"
-                       ]
+                       ],
+                       null
                );
 
                $mockDB1->expects( $this->exactly( 1 ) )->method( 'writesOrCallbacksPending' );
@@ -357,11 +356,11 @@ class LBFactoryTest extends MediaWikiTestCase {
                $mockDB2->expects( $this->exactly( 1 ) )->method( 'lastDoneWrites' );
 
                // Nothing to wait for on first HTTP request start
-               $cp->initLB( $lb1 );
-               $cp->initLB( $lb2 );
+               $cp->applySessionReplicationPosition( $lb1 );
+               $cp->applySessionReplicationPosition( $lb2 );
                // Record positions in stash on first HTTP request end
-               $cp->shutdownLB( $lb1 );
-               $cp->shutdownLB( $lb2 );
+               $cp->storeSessionReplicationPosition( $lb1 );
+               $cp->storeSessionReplicationPosition( $lb2 );
                $cpIndex = null;
                $cp->shutdown( null, 'sync', $cpIndex );
 
@@ -396,11 +395,11 @@ class LBFactoryTest extends MediaWikiTestCase {
                );
 
                // Wait for last positions to be reached on second HTTP request start
-               $cp->initLB( $lb1 );
-               $cp->initLB( $lb2 );
+               $cp->applySessionReplicationPosition( $lb1 );
+               $cp->applySessionReplicationPosition( $lb2 );
                // Shutdown (nothing to record)
-               $cp->shutdownLB( $lb1 );
-               $cp->shutdownLB( $lb2 );
+               $cp->storeSessionReplicationPosition( $lb1 );
+               $cp->storeSessionReplicationPosition( $lb2 );
                $cpIndex = null;
                $cp->shutdown( null, 'sync', $cpIndex );
 
@@ -730,7 +729,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                $factory->destroy();
        }
 
-       private function quoteTable( Database $db, $table ) {
+       private function quoteTable( IDatabase $db, $table ) {
                if ( $db->getType() === 'sqlite' ) {
                        return $table;
                } else {