->setMethods( [ 'fetchRow', 'query' ] )
->getMock();
- $db->expects( $this->any() )
- ->method( 'query' )
+ $db->method( 'query' )
->with( $this->anything() )
- ->will(
- $this->returnValue( null )
- );
+ ->willReturn( null );
- $db->expects( $this->any() )
- ->method( 'fetchRow' )
+ $db->method( 'fetchRow' )
->with( $this->anything() )
->will( $this->onConsecutiveCalls(
[ 'Tables_in_' => 'view1' ],
'getLagDetectionMethod', 'getHeartbeatData', 'getMasterServerInfo' ] )
->getMock();
- $db->expects( $this->any() )
- ->method( 'getLagDetectionMethod' )
- ->will( $this->returnValue( 'pt-heartbeat' ) );
+ $db->method( 'getLagDetectionMethod' )
+ ->willReturn( 'pt-heartbeat' );
- $db->expects( $this->any() )
- ->method( 'getMasterServerInfo' )
- ->will( $this->returnValue( [ 'serverId' => 172, 'asOf' => time() ] ) );
+ $db->method( 'getMasterServerInfo' )
+ ->willReturn( [ 'serverId' => 172, 'asOf' => time() ] );
// Fake the current time.
list( $nowSecFrac, $nowSec ) = explode( ' ', microtime() );
$ptTimeISO = $ptDateTime->format( 'Y-m-d\TH:i:s' );
$ptTimeISO .= ltrim( number_format( $ptSecFrac, 6 ), '0' );
- $db->expects( $this->any() )
- ->method( 'getHeartbeatData' )
+ $db->method( 'getHeartbeatData' )
->with( [ 'server_id' => 172 ] )
- ->will( $this->returnValue( [ $ptTimeISO, $now ] ) );
+ ->willReturn( [ $ptTimeISO, $now ] );
$db->setLBInfo( 'clusterMasterHost', 'db1052' );
$lagEst = $db->getLag();
$mockDB = $this->getMockBuilder( 'DatabaseMysql' )
->disableOriginalConstructor()
->getMock();
- $mockDB->expects( $this->any() )
- ->method( 'writesOrCallbacksPending' )->will( $this->returnValue( true ) );
- $mockDB->expects( $this->any() )
- ->method( 'lastDoneWrites' )->will( $this->returnValue( $now ) );
- $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->expects( $this->any() )
- ->method( 'hasOrMadeRecentMasterChanges' )->will( $this->returnCallback(
+ $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' ] );
return (bool)$p;
}
) );
- $lb->expects( $this->any() )
- ->method( 'getMasterPos' )->will( $this->returnValue( $mPos ) );
+ $lb->method( 'getMasterPos' )->willReturn( $mPos );
$bag = new HashBagOStuff();
$cp = new ChronologyProtector(