];
$this->hideDeprecated( '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details' );
- $result = LBFactory::getLBFactoryClass( $config );
+ $result = LBFactoryMW::getLBFactoryClass( $config );
$this->assertEquals( $expected, $result );
}
[ 'LBFactorySimple', 'LBFactory_Simple' ],
[ 'LBFactorySingle', 'LBFactory_Single' ],
[ 'LBFactoryMulti', 'LBFactory_Multi' ],
- [ 'LBFactoryFake', 'LBFactory_Fake' ],
];
}
$wgDBserver, $dbw->getLBInfo( 'clusterMasterHost' ), 'cluster master set' );
$dbr = $lb->getConnection( DB_SLAVE );
- $this->assertTrue( $dbr->getLBInfo( 'slave' ), 'slave shows as slave' );
+ $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
$this->assertEquals(
$wgDBserver, $dbr->getLBInfo( 'clusterMasterHost' ), 'cluster master set' );
$this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
$dbr = $lb->getConnection( DB_SLAVE );
- $this->assertTrue( $dbr->getLBInfo( 'slave' ), 'slave shows as slave' );
+ $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
$factory->shutdown();
$lb->closeAll();
// (a) First HTTP request
$mPos = new MySQLMasterPos( 'db1034-bin.000976', '843431247' );
+ $now = microtime( true );
$mockDB = $this->getMockBuilder( 'DatabaseMysql' )
->disableOriginalConstructor()
->getMock();
- $mockDB->expects( $this->any() )
- ->method( 'doneWrites' )->will( $this->returnValue( true ) );
- $mockDB->expects( $this->any() )
- ->method( 'getMasterPos' )->will( $this->returnValue( $mPos ) );
+ $mockDB->method( 'writesOrCallbacksPending' )->willReturn( true );
+ $mockDB->method( 'lastDoneWrites' )->willReturn( $now );
+ $mockDB->method( 'getMasterPos' )->willReturn( $mPos );
$lb = $this->getMockBuilder( 'LoadBalancer' )
->disableOriginalConstructor()
->getMock();
- $lb->expects( $this->any() )
- ->method( 'getConnection' )->will( $this->returnValue( $mockDB ) );
- $lb->expects( $this->any() )
- ->method( 'getServerCount' )->will( $this->returnValue( 2 ) );
- $lb->expects( $this->any() )
- ->method( 'parentInfo' )->will( $this->returnValue( [ 'id' => "main-DEFAULT" ] ) );
- $lb->expects( $this->any() )
- ->method( 'getAnyOpenConnection' )->will( $this->returnValue( $mockDB ) );
+ $lb->method( 'getConnection' )->willReturn( $mockDB );
+ $lb->method( 'getServerCount' )->willReturn( 2 );
+ $lb->method( 'parentInfo' )->willReturn( [ 'id' => "main-DEFAULT" ] );
+ $lb->method( 'getAnyOpenConnection' )->willReturn( $mockDB );
+ $lb->method( 'hasOrMadeRecentMasterChanges' )->will( $this->returnCallback(
+ function () use ( $mockDB ) {
+ $p = 0;
+ $p |= call_user_func( [ $mockDB, 'writesOrCallbacksPending' ] );
+ $p |= call_user_func( [ $mockDB, 'lastDoneWrites' ] );
+
+ return (bool)$p;
+ }
+ ) );
+ $lb->method( 'getMasterPos' )->willReturn( $mPos );
$bag = new HashBagOStuff();
$cp = new ChronologyProtector(
]
);
- $mockDB->expects( $this->exactly( 2 ) )->method( 'doneWrites' );
+ $mockDB->expects( $this->exactly( 2 ) )->method( 'writesOrCallbacksPending' );
+ $mockDB->expects( $this->exactly( 2 ) )->method( 'lastDoneWrites' );
// Nothing to wait for
$cp->initLB( $lb );