From ec215d010c16285a7da5c7a1a0ccc8fb26341ca5 Mon Sep 17 00:00:00 2001 From: Seb35 Date: Sat, 31 Dec 2016 12:52:16 +0100 Subject: [PATCH] Replace mocks of DatabaseMysql by DatabaseMysqli The class DatabaseMysql corresponds to the PHP extension 'mysql' which is deprecated since PHP 5.5, and the class DatabaseMysqli corresponds to the PHP extension 'mysqli' which is the current MySQL driver. Given the class DatabaseMysql is likely to be removed in the future, this change is a first step towards this. Bug: T120333 Change-Id: I7b8363838449cae09b360221d8f50ace3a008f11 --- tests/phpunit/includes/db/DatabaseMysqlBaseTest.php | 4 ++-- tests/phpunit/includes/db/LBFactoryTest.php | 4 ++-- .../includes/filerepo/FileBackendDBRepoWrapperTest.php | 2 +- tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php | 2 +- tests/phpunit/includes/utils/BatchRowUpdateTest.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php index dbb126f300..81b75dea17 100644 --- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php +++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php @@ -170,7 +170,7 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase { } function getMockForViews() { - $db = $this->getMockBuilder( 'DatabaseMysql' ) + $db = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->setMethods( [ 'fetchRow', 'query' ] ) ->getMock(); @@ -314,7 +314,7 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase { * @dataProvider provideLagAmounts */ function testPtHeartbeat( $lag ) { - $db = $this->getMockBuilder( 'DatabaseMysql' ) + $db = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->setMethods( [ 'getLagDetectionMethod', 'getHeartbeatData', 'getMasterServerInfo' ] ) diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index d8773f8ad2..573b395805 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -29,7 +29,7 @@ class LBFactoryTest extends MediaWikiTestCase { * @dataProvider getLBFactoryClassProvider */ public function testGetLBFactoryClass( $expected, $deprecated ) { - $mockDB = $this->getMockBuilder( 'DatabaseMysql' ) + $mockDB = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->getMock(); @@ -178,7 +178,7 @@ class LBFactoryTest extends MediaWikiTestCase { $mPos = new MySQLMasterPos( 'db1034-bin.000976', '843431247' ); $now = microtime( true ); - $mockDB = $this->getMockBuilder( 'DatabaseMysql' ) + $mockDB = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->getMock(); $mockDB->method( 'writesOrCallbacksPending' )->willReturn( true ); diff --git a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php index 836654103c..410d2df217 100644 --- a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php +++ b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php @@ -112,7 +112,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiTestCase { } protected function getMocks() { - $dbMock = $this->getMockBuilder( 'DatabaseMysql' ) + $dbMock = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php index 92a54faca1..d3f9374c53 100644 --- a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php +++ b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php @@ -25,7 +25,7 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase { ] ] ); - $dbMock = $this->getMockBuilder( 'DatabaseMysql' ) + $dbMock = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/includes/utils/BatchRowUpdateTest.php index cb1b3d2af6..6506d58e21 100644 --- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php @@ -237,7 +237,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase { protected function mockDb() { // @TODO: mock from Database // FIXME: the constructor normally sets mAtomicLevels and mSrvCache - $databaseMysql = $this->getMockBuilder( 'DatabaseMysql' ) + $databaseMysql = $this->getMockBuilder( 'DatabaseMysqli' ) ->disableOriginalConstructor() ->getMock(); $databaseMysql->expects( $this->any() ) -- 2.20.1