returned regardless.
=== Action API internal changes in 1.31 ===
-* …
+* ApiBase::getProfileDBTime was removed (deprecated since 1.25)
+* ApiBase::getModuleProfileName was removed (deprecated since 1.25)
+* ApiBase::getProfileTime was removed (deprecated since 1.25)
=== Languages updated in 1.31 ===
MediaWiki supports over 350 languages. Many localisations are updated
* @file
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
/**
* The TitleArray class only exists to provide the newFromResult method at pre-
*/
abstract class TitleArray implements Iterator {
/**
- * @param ResultWrapper $res A SQL result including at least page_namespace and
+ * @param IResultWrapper $res A SQL result including at least page_namespace and
* page_title -- also can have page_id, page_len, page_is_redirect,
* page_latest (if those will be used). See Title::newFromRow.
* @return TitleArrayFromResult
}
/**
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
* @return TitleArrayFromResult
*/
protected static function newFromResult_internal( $res ) {
* @file
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
class TitleArrayFromResult extends TitleArray implements Countable {
- /** @var ResultWrapper */
+ /** @var IResultWrapper */
public $res;
public $key;
}
/**
- * @param bool|ResultWrapper $row
+ * @param bool|IResultWrapper $row
* @return void
*/
protected function setCurrent( $row ) {
return false;
}
- /**
- * @deprecated since 1.25, always returns empty string
- * @param IDatabase|bool $db
- * @return string
- */
- public function getModuleProfileName( $db = false ) {
- wfDeprecated( __METHOD__, '1.25' );
- return '';
- }
-
/**
* @deprecated since 1.25
*/
wfDeprecated( __METHOD__, '1.25' );
}
- /**
- * @deprecated since 1.25, always returns 0
- * @return float
- */
- public function getProfileTime() {
- wfDeprecated( __METHOD__, '1.25' );
- return 0;
- }
-
/**
* @deprecated since 1.25
*/
wfDeprecated( __METHOD__, '1.25' );
}
- /**
- * @deprecated since 1.25, always returns 0
- * @return float
- */
- public function getProfileDBTime() {
- wfDeprecated( __METHOD__, '1.25' );
- return 0;
- }
-
/**
* Call wfTransactionalTimeLimit() if this request was POSTed
* @since 1.26
* @ingroup Pager
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
/**
* Result object for the query. Warning: seek before use.
*
- * @var ResultWrapper
+ * @var IResultWrapper
*/
public $mResult;
}
/**
- * @return ResultWrapper The result wrapper.
+ * @return IResultWrapper The result wrapper.
*/
function getResult() {
return $this->mResult;
* @param bool $isFirst False if there are rows before those fetched (i.e.
* if a "previous" link would make sense)
* @param int $limit Exact query limit
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
- function extractResultInfo( $isFirst, $limit, ResultWrapper $res ) {
+ function extractResultInfo( $isFirst, $limit, IResultWrapper $res ) {
$numRows = $res->numRows();
if ( $numRows ) {
# Remove any table prefix from index field
* @param string $offset Index offset, inclusive
* @param int $limit Exact query limit
* @param bool $descending Query direction, false for ascending, true for descending
- * @return ResultWrapper
+ * @return IResultWrapper
*/
public function reallyDoQuery( $offset, $limit, $descending ) {
list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
/**
* Pre-process results; useful for performing batch existence checks, etc.
*
- * @param ResultWrapper $result
+ * @param IResultWrapper $result
*/
protected function preprocessResults( $result ) {
}
/**
* @throws MWException
* @param array $m
- * @return HTML|string
+ * @return string HTML
*/
public function magicLinkCallback( $m ) {
if ( isset( $m[1] ) && $m[1] !== '' ) {
/* these are used extensively in SkinTemplate, but also some other places */
/**
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @return string
*/
static function makeMainPageUrl( $urlaction = '' ) {
* URL with the protocol specified.
*
* @param string $name Name of the Special page
- * @param string $urlaction Query to append
+ * @param string|string[] $urlaction Query to append
* @param string|null $proto Protocol to use or null for a local URL
* @return string
*/
/**
* @param string $name
* @param string $subpage
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @return string
*/
static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
/**
* @param string $name
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @return string
*/
static function makeI18nUrl( $name, $urlaction = '' ) {
/**
* @param string $name
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @return string
*/
static function makeUrl( $name, $urlaction = '' ) {
/**
* this can be passed the NS number as defined in Language.php
* @param string $name
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @param int $namespace
* @return string
*/
/**
* these return an array with the 'href' and boolean 'exists'
* @param string $name
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @return array
*/
static function makeUrlDetails( $name, $urlaction = '' ) {
/**
* Make URL details where the article exists (or at least it's convenient to think so)
* @param string $name Article name
- * @param string $urlaction
+ * @param string|string[] $urlaction
* @return array
*/
static function makeKnownUrlDetails( $name, $urlaction = '' ) {
*/
use MediaWiki\Logger\LoggerFactory;
use Wikimedia\Rdbms\DBQueryTimeoutError;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Get the database result for this special page instance. Used by ApiFeedRecentChanges.
*
- * @return bool|ResultWrapper Result or false
+ * @return bool|IResultWrapper Result or false
*/
public function getRows() {
$opts = $this->getOptions();
* @param array $query_options Array of query options; see IDatabase::select $options
* @param array $join_conds Array of join conditions; see IDatabase::select $join_conds
* @param FormOptions $opts
- * @return bool|ResultWrapper Result or false
+ * @return bool|IResultWrapper Result or false
*/
protected function doMainQuery( $tables, $fields, $conds,
$query_options, $join_conds, FormOptions $opts
/**
* Send output to the OutputPage object, only called if not used feeds
*
- * @param ResultWrapper $rows Database rows
+ * @param IResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function webOutput( $rows, $opts ) {
/**
* Build and output the actual changes list.
*
- * @param ResultWrapper $rows Database rows
+ * @param IResultWrapper $rows Database rows
* @param FormOptions $opts
*/
abstract public function outputChangesList( $rows, $opts );
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* @param OutputPage $out OutputPage to print to
* @param Skin $skin User skin to use [unused]
* @param IDatabase $dbr (read) connection to use
- * @param ResultWrapper $res Result pointer
+ * @param IResultWrapper $res Result pointer
* @param int $num Number of available result rows
* @param int $offset Paging offset
*/
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* This should be done for live data and cached data.
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
public function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\DBError;
* Run the query and return the result
* @param int|bool $limit Numerical limit or false for no limit
* @param int|bool $offset Numerical offset or false for no offset
- * @return ResultWrapper
+ * @return IResultWrapper
* @since 1.18
*/
public function reallyDoQuery( $limit, $offset = false ) {
* Somewhat deprecated, you probably want to be using execute()
* @param int|bool $offset
* @param int|bool $limit
- * @return ResultWrapper
+ * @return IResultWrapper
*/
public function doQuery( $offset = false, $limit = false ) {
if ( $this->isCached() && $this->isCacheable() ) {
* Fetch the query results from the query cache
* @param int|bool $limit Numerical limit or false for no limit
* @param int|bool $offset Numerical offset or false for no offset
- * @return ResultWrapper
+ * @return IResultWrapper
* @since 1.18
*/
public function fetchFromCache( $limit, $offset = false ) {
* @param OutputPage $out OutputPage to print to
* @param Skin $skin User skin to use
* @param IDatabase $dbr Database (read) connection to use
- * @param ResultWrapper $res Result pointer
+ * @param IResultWrapper $res Result pointer
* @param int $num Number of available result rows
* @param int $offset Paging offset
*/
/**
* Do any necessary preprocessing of the result object.
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
}
* title and optional the namespace field) and executes the batch. This operation will pre-cache
* LinkCache information like page existence and information for stub color and redirect hints.
*
- * @param ResultWrapper $res The ResultWrapper object to process. Needs to include the title
+ * @param IResultWrapper $res The ResultWrapper object to process. Needs to include the title
* field and namespace field, if the $ns parameter isn't set.
* @param null $ns Use this namespace for the given titles in the ResultWrapper object,
* instead of the namespace value of $res.
*/
- protected function executeLBFromResultWrapper( ResultWrapper $res, $ns = null ) {
+ protected function executeLBFromResultWrapper( IResultWrapper $res, $ns = null ) {
if ( !$res->numRows() ) {
return;
}
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
/**
* Cache page existence for performance
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Cache page content model for performance
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Cache page content model and gender distinction for performance
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
if ( !$res->numRows() ) {
* @author Brion Vibber
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Pre-fill the link cache
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @author Brian Wolff
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Pre-fill the link cache
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @author Rob Church <robchur@gmail.com>
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Cache page existence for performance
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
if ( !$res->numRows() ) {
* @author Brian Wolff
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* @param OutputPage $out
* @param Skin $skin (deprecated presumably)
* @param IDatabase $dbr
- * @param ResultWrapper $res Results from query
+ * @param IResultWrapper $res Results from query
* @param int $num Number of results
* @param int $offset Paging offset (Should always be 0 in our case)
*/
* Initialize total values so we can figure out percentages later.
*
* @param IDatabase $dbr
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
public function preprocessResults( $dbr, $res ) {
$this->executeLBFromResultWrapper( $res );
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
/**
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Pre-fill the link cache
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @author Rob Church <robchur@gmail.com>
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Pre-fill the link cache
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Fetch user page links and cache their existence
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @author Rob Church <robchur@gmail.com>
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Pre-cache page existence to speed up link generation
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
public function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
/**
/**
* Build and output the actual changes list.
*
- * @param ResultWrapper $rows Database rows
+ * @param IResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function outputChangesList( $rows, $opts ) {
*
* @deprecated since 1.31
*
- * @param ResultWrapper &$rows Database rows
+ * @param IResultWrapper &$rows Database rows
* @param FormOptions $opts
*/
function filterByCategories( &$rows, FormOptions $opts ) {
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
/**
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function preprocessResults( $db, $res ) {
$this->executeLBFromResultWrapper( $res );
* @ingroup SpecialPage
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
/**
* Special page allowing users with the appropriate permissions to view
/**
* Generic list of deleted pages
*
- * @param ResultWrapper $result
+ * @param IResultWrapper $result
* @return bool
*/
private function showList( $result ) {
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
* Pre-cache page existence to speed up link generation
*
* @param IDatabase $db
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
public function preprocessResults( $db, $res ) {
if ( !$res->numRows() ) {
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\IDatabase;
/**
/**
* Build and output the actual changes list.
*
- * @param ResultWrapper $rows Database rows
+ * @param IResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function outputChangesList( $rows, $opts ) {
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
class BlockListPager extends TablePager {
/**
* Do a LinkBatch query to minimise database load when generating all these links
- * @param ResultWrapper $result
+ * @param IResultWrapper $result
*/
function preprocessResults( $result ) {
# Do a link batch query
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
use Wikimedia\Rdbms\IDatabase;
* @param string $offset Index offset, inclusive
* @param int $limit Exact query limit
* @param bool $descending Query direction, false for ascending, true for descending
- * @return ResultWrapper
+ * @return IResultWrapper
*/
function reallyDoQuery( $offset, $limit, $descending ) {
list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo(
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
class DeletedContribsPager extends IndexPager {
* @param string $offset Index offset, inclusive
* @param int $limit Exact query limit
* @param bool $descending Query direction, false for ascending, true for descending
- * @return ResultWrapper
+ * @return IResultWrapper
*/
function reallyDoQuery( $offset, $limit, $descending ) {
$data = [ parent::reallyDoQuery( $offset, $limit, $descending ) ];
* @ingroup Pager
*/
use MediaWiki\MediaWikiServices;
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
use Wikimedia\Rdbms\FakeResultWrapper;
class ImageListPager extends TablePager {
*
* Note: This will throw away some results
*
- * @param ResultWrapper $res1
- * @param ResultWrapper $res2
+ * @param IResultWrapper $res1
+ * @param IResultWrapper $res2
* @param int $limit
* @param bool $ascending See note about $asc in $this->reallyDoQuery
* @return FakeResultWrapper $res1 and $res2 combined
* @file
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
abstract class UserArray implements Iterator {
/**
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
* @return UserArrayFromResult
*/
static function newFromResult( $res ) {
}
/**
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
* @return UserArrayFromResult
*/
protected static function newFromResult_internal( $res ) {
* @file
*/
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
class UserArrayFromResult extends UserArray implements Countable {
- /** @var ResultWrapper */
+ /** @var IResultWrapper */
public $res;
/** @var int */
public $current;
/**
- * @param ResultWrapper $res
+ * @param IResultWrapper $res
*/
function __construct( $res ) {
$this->res = $res;
* @param string $details HTML safe text between brackets
* @param bool $oppositedm Add the direction mark opposite to your
* language, to display text properly
- * @return HTML escaped string
+ * @return string HTML escaped
*/
function specialList( $page, $details, $oppositedm = true ) {
if ( !$details ) {
"password-login-forbidden": "The use of this username and password has been forbidden.",
"mailmypassword": "Reset password",
"passwordremindertitle": "New temporary password for {{SITENAME}}",
- "passwordremindertext": "Someone (probably you, from IP address $1) requested a new\npassword for {{SITENAME}} ($4). A temporary password for user\n\"$2\" has been created and was set to \"$3\". If this was your\nintent, you will need to log in and choose a new password now.\nYour temporary password will expire in {{PLURAL:$5|one day|$5 days}}.\n\nIf someone else made this request, or if you have remembered your password,\nand you no longer wish to change it, you may ignore this message and\ncontinue using your old password.",
+ "passwordremindertext": "Someone (from IP address $1) requested a new\npassword for {{SITENAME}} ($4). A temporary password for user\n\"$2\" has been created and was set to \"$3\". If this was your\nintent, you will need to log in and choose a new password now.\nYour temporary password will expire in {{PLURAL:$5|one day|$5 days}}.\n\nIf someone else made this request, or if you have remembered your password,\nand you no longer wish to change it, you may ignore this message and\ncontinue using your old password.",
"noemail": "There is no email address recorded for user \"$1\".",
"noemailcreate": "You need to provide a valid email address.",
"passwordsent": "A new password has been sent to the email address registered for \"$1\".\nPlease log in again after you receive it.",
'TestUserRegistry' => "$testDir/phpunit/includes/TestUserRegistry.php",
'LessFileCompilationTest' => "$testDir/phpunit/LessFileCompilationTest.php",
'MediaWikiCoversValidator' => "$testDir/phpunit/MediaWikiCoversValidator.php",
+ 'PHPUnit4And6Compat' => "$testDir/phpunit/PHPUnit4And6Compat.php",
# tests/phpunit/includes
'RevisionDbTestBase' => "$testDir/phpunit/includes/RevisionDbTestBase.php",
'ParserTestTopLevelSuite' => "$testDir/phpunit/suites/ParserTestTopLevelSuite.php",
];
// phpcs:enable
+
+/**
+ * Alias any PHPUnit 4 era PHPUnit_... class
+ * to it's PHPUnit 6 replacement. For most classes
+ * this is a direct _ -> \ replacement, but for
+ * some others we might need to maintain a manual
+ * mapping. Once we drop support for PHPUnit 4 this
+ * should be considered deprecated and eventually removed.
+ */
+spl_autoload_register( function ( $class ) {
+ if ( strpos( $class, 'PHPUnit_' ) !== 0 ) {
+ // Skip if it doesn't start with the old prefix
+ return;
+ }
+
+ // Classes that don't map 100%
+ $map = [
+ 'PHPUnit_Framework_TestSuite_DataProvider' => 'PHPUnit\Framework\DataProviderTestSuite'
+ ];
+
+ if ( isset( $map[$class] ) ) {
+ $newForm = $map[$class];
+ } else {
+ $newForm = str_replace( '_', '\\', $class );
+ }
+
+ if ( class_exists( $newForm ) ) {
+ // If the new class name exists, alias
+ // the old name to it.
+ class_alias( $newForm, $class );
+ }
+} );
abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
use MediaWikiCoversValidator;
+ use PHPUnit4And6Compat;
/**
* The service locator created by prepareServices(). This service locator will
}
}
- /**
- * @since 1.18
- *
- * @param string $func
- * @param array $args
- *
- * @return mixed
- * @throws MWException
- */
- public function __call( $func, $args ) {
- static $compatibility = [
- 'createMock' => 'createMock2',
- ];
-
- if ( isset( $compatibility[$func] ) ) {
- return call_user_func_array( [ $this, $compatibility[$func] ], $args );
- } else {
- throw new MWException( "Called non-existent $func method on " . static::class );
- }
- }
-
- /**
- * Return a test double for the specified class.
- *
- * @param string $originalClassName
- * @return PHPUnit_Framework_MockObject_MockObject
- * @throws Exception
- */
- private function createMock2( $originalClassName ) {
- return $this->getMockBuilder( $originalClassName )
- ->disableOriginalConstructor()
- ->disableOriginalClone()
- ->disableArgumentCloning()
- // New in phpunit-mock-objects 3.2 (phpunit 5.4.0)
- // ->disallowMockingUnknownTypes()
- ->getMock();
- }
-
private static function unprefixTable( &$tableName, $ind, $prefix ) {
$tableName = substr( $tableName, strlen( $prefix ) );
}
--- /dev/null
+<?php
+/**
+ * Copyright (C) 2018 Kunal Mehta <legoktm@member.fsf.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+/**
+ * @since 1.31
+ */
+trait PHPUnit4And6Compat {
+ /**
+ * @see PHPUnit_Framework_TestCase::setExpectedException
+ *
+ * This function was renamed to expectException() in PHPUnit 6, so this
+ * is a temporary backwards-compatibility layer while we transition.
+ */
+ public function setExpectedException( $name, $message = '', $code = null ) {
+ if ( is_callable( [ $this, 'expectException' ] ) ) {
+ $this->expectException( $name );
+ if ( $message !== '' ) {
+ $this->expectExceptionMessage( $message );
+ }
+ if ( $code !== null ) {
+ $this->expectExceptionCode( $code );
+ }
+ } else {
+ parent::setExpectedException( $name, $message, $code );
+ }
+ }
+
+ /**
+ * @see PHPUnit_Framework_TestCase::getMock
+ *
+ * @return PHPUnit_Framework_MockObject_MockObject
+ */
+ public function getMock( $originalClassName, $methods = [], array $arguments = [],
+ $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true,
+ $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false,
+ $proxyTarget = null
+ ) {
+ if ( is_callable( 'parent::getMock' ) ) {
+ return parent::getMock(
+ $originalClassName, $methods, $arguments, $mockClassName,
+ $callOriginalConstructor, $callOriginalClone, $callAutoload,
+ $cloneArguments, $callOriginalMethods, $proxyTarget
+ );
+ } else {
+ $builder = $this->getMockBuilder( $originalClassName )
+ ->setMethods( $methods )
+ ->setConstructorArgs( $arguments )
+ ->setMockClassName( $mockClassName )
+ ->setProxyTarget( $proxyTarget );
+ if ( $callOriginalConstructor ) {
+ $builder->enableOriginalConstructor();
+ } else {
+ $builder->disableOriginalConstructor();
+ }
+ if ( $callOriginalClone ) {
+ $builder->enableOriginalClone();
+ } else {
+ $builder->disableOriginalClone();
+ }
+ if ( $callAutoload ) {
+ $builder->enableAutoload();
+ } else {
+ $builder->disableAutoload();
+ }
+ if ( $cloneArguments ) {
+ $builder->enableArgumentCloning();
+ } else {
+ $builder->disableArgumentCloning();
+ }
+ if ( $callOriginalMethods ) {
+ $builder->enableProxyingToOriginalMethods();
+ } else {
+ $builder->disableProxyingToOriginalMethods();
+ }
+
+ return $builder->getMock();
+ }
+ }
+
+ /**
+ * Return a test double for the specified class. This
+ * is a forward port of the createMock function that
+ * was introduced in PHPUnit 5.4.
+ *
+ * @param string $originalClassName
+ * @return PHPUnit_Framework_MockObject_MockObject
+ * @throws Exception
+ */
+ public function createMock( $originalClassName ) {
+ if ( is_callable( 'parent::createMock' ) ) {
+ return parent::createMock( $originalClassName );
+ }
+ // Compat for PHPUnit <= 5.4
+ return $this->getMockBuilder( $originalClassName )
+ ->disableOriginalConstructor()
+ ->disableOriginalClone()
+ ->disableArgumentCloning()
+ // New in phpunit-mock-objects 3.2 (phpunit 5.4.0)
+ // ->disallowMockingUnknownTypes()
+ ->getMock();
+ }
+}