X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FStorage%2FNameTableStoreTest.php;h=47d3b92747063e7d07490831f45974e002487a0b;hp=f42e557b770f9d1fbc27bef823415b4990b4174d;hb=04d1aa3033f40a38d721f7f0e88b5bac440d2869;hpb=0f24b13ea03a7226bd7b9f0d84f4deee8bea0736 diff --git a/tests/phpunit/includes/Storage/NameTableStoreTest.php b/tests/phpunit/includes/Storage/NameTableStoreTest.php index f42e557b77..47d3b92747 100644 --- a/tests/phpunit/includes/Storage/NameTableStoreTest.php +++ b/tests/phpunit/includes/Storage/NameTableStoreTest.php @@ -10,7 +10,7 @@ use MediaWiki\Storage\NameTableStore; use MediaWikiTestCase; use Psr\Log\NullLogger; use WANObjectCache; -use Wikimedia\Rdbms\Database; +use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\LoadBalancer; use Wikimedia\TestingAccessWrapper; @@ -57,29 +57,25 @@ class NameTableStoreTest extends MediaWikiTestCase { } private function getCallCheckingDb( $insertCalls, $selectCalls ) { - $mock = $this->getMockBuilder( Database::class ) + $proxiedMethods = [ + 'select' => $selectCalls, + 'insert' => $insertCalls, + 'affectedRows' => null, + 'insertId' => null, + 'getSessionLagStatus' => null, + 'writesPending' => null, + 'onTransactionPreCommitOrIdle' => null + ]; + $mock = $this->getMockBuilder( IDatabase::class ) ->disableOriginalConstructor() ->getMock(); - $mock->expects( $this->exactly( $insertCalls ) ) - ->method( 'insert' ) - ->willReturnCallback( function ( ...$args ) { - return call_user_func_array( [ $this->db, 'insert' ], $args ); - } ); - $mock->expects( $this->exactly( $selectCalls ) ) - ->method( 'select' ) - ->willReturnCallback( function ( ...$args ) { - return call_user_func_array( [ $this->db, 'select' ], $args ); - } ); - $mock->expects( $this->exactly( $insertCalls ) ) - ->method( 'affectedRows' ) - ->willReturnCallback( function ( ...$args ) { - return call_user_func_array( [ $this->db, 'affectedRows' ], $args ); - } ); - $mock->expects( $this->any() ) - ->method( 'insertId' ) - ->willReturnCallback( function ( ...$args ) { - return call_user_func_array( [ $this->db, 'insertId' ], $args ); - } ); + foreach ( $proxiedMethods as $method => $count ) { + $mock->expects( is_int( $count ) ? $this->exactly( $count ) : $this->any() ) + ->method( $method ) + ->willReturnCallback( function ( ...$args ) use ( $method ) { + return call_user_func_array( [ $this->db, $method ], $args ); + } ); + } return $mock; }