X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fdb%2FDatabaseMysqlBaseTest.php;h=3b695908789c570f19ebcfefb91afc968f5d93b4;hb=830a60aa827cdb44af17452e6b82e1065e00d8ad;hp=9480c2df2d89943129c0b6c5a7f5732305e5b6d6;hpb=711fad668b86ff837a31808fe71056b9257e4d80;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php index 9480c2df2d..3b69590878 100644 --- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php +++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php @@ -25,11 +25,13 @@ * @copyright © 2013 Wikimedia Foundation Inc. */ +use Wikimedia\Rdbms\TransactionProfiler; + /** * Fake class around abstract class so we can call concrete methods. */ class FakeDatabaseMysqlBase extends DatabaseMysqlBase { - // From DatabaseBase + // From Database function __construct() { $this->profiler = new ProfilerStub( [] ); $this->trxProfiler = new TransactionProfiler(); @@ -89,7 +91,6 @@ class FakeDatabaseMysqlBase extends DatabaseMysqlBase { } - // From interface DatabaseType function insertId() { } @@ -171,23 +172,19 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase { } function getMockForViews() { - $db = $this->getMockBuilder( 'DatabaseMysql' ) + $db = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->setMethods( [ 'fetchRow', 'query' ] ) ->getMock(); $db->method( 'query' ) ->with( $this->anything() ) - ->willReturn( null ); + ->willReturn( new FakeResultWrapper( [ + (object)[ 'Tables_in_' => 'view1' ], + (object)[ 'Tables_in_' => 'view2' ], + (object)[ 'Tables_in_' => 'myview' ] + ] ) ); - $db->method( 'fetchRow' ) - ->with( $this->anything() ) - ->will( $this->onConsecutiveCalls( - [ 'Tables_in_' => 'view1' ], - [ 'Tables_in_' => 'view2' ], - [ 'Tables_in_' => 'myview' ], - false # no more rows - ) ); return $db; } /** @@ -196,9 +193,6 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase { function testListviews() { $db = $this->getMockForViews(); - // The first call populate an internal cache of views - $this->assertEquals( [ 'view1', 'view2', 'myview' ], - $db->listViews() ); $this->assertEquals( [ 'view1', 'view2', 'myview' ], $db->listViews() ); @@ -213,42 +207,6 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase { $db->listViews( '' ) ); } - /** - * @covers DatabaseMysqlBase::isView - * @dataProvider provideViewExistanceChecks - */ - function testIsView( $isView, $viewName ) { - $db = $this->getMockForViews(); - - switch ( $isView ) { - case true: - $this->assertTrue( $db->isView( $viewName ), - "$viewName should be considered a view" ); - break; - - case false: - $this->assertFalse( $db->isView( $viewName ), - "$viewName has not been defined as a view" ); - break; - } - - } - - function provideViewExistanceChecks() { - return [ - // format: whether it is a view, view name - [ true, 'view1' ], - [ true, 'view2' ], - [ true, 'myview' ], - - [ false, 'user' ], - - [ false, 'view10' ], - [ false, 'my' ], - [ false, 'OH_MY_GOD' ], # they killed kenny! - ]; - } - /** * @dataProvider provideComparePositions */ @@ -358,7 +316,7 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase { * @dataProvider provideLagAmounts */ function testPtHeartbeat( $lag ) { - $db = $this->getMockBuilder( 'DatabaseMysql' ) + $db = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->setMethods( [ 'getLagDetectionMethod', 'getHeartbeatData', 'getMasterServerInfo' ] )