diff options
72 files changed, 223 insertions, 217 deletions
diff --git a/.phpcs.xml b/.phpcs.xml index 75f55f27e91a..a64139f84a98 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -21,6 +21,12 @@ <exclude name="Squiz.Scope.MethodScope.Missing" /> <exclude name="MediaWiki.PHP71Features.NullableType.NotAllowed" /> </rule> + <!-- TODO Still to be done --> + <rule ref="Squiz.Scope.MethodScope.Missing"> + <exclude-pattern>includes/</exclude-pattern> + <exclude-pattern>maintenance/</exclude-pattern> + <exclude-pattern>languages/</exclude-pattern> + </rule> <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions"> <properties> <!-- diff --git a/tests/parser/DbTestPreviewer.php b/tests/parser/DbTestPreviewer.php index 33aee7d304be..b0c88bead2d2 100644 --- a/tests/parser/DbTestPreviewer.php +++ b/tests/parser/DbTestPreviewer.php @@ -32,7 +32,7 @@ class DbTestPreviewer extends TestRecorder { * @param IDatabase $db * @param bool|string $filter */ - function __construct( $db, $filter = false ) { + public function __construct( $db, $filter = false ) { $this->db = $db; $this->filter = $filter; } @@ -41,7 +41,7 @@ class DbTestPreviewer extends TestRecorder { * Set up result recording; insert a record for the run with the date * and all that fun stuff */ - function start() { + public function start() { if ( !$this->db->tableExists( 'testrun', __METHOD__ ) || !$this->db->tableExists( 'testitem', __METHOD__ ) ) { @@ -55,11 +55,11 @@ class DbTestPreviewer extends TestRecorder { $this->results = []; } - function record( $test, ParserTestResult $result ) { + public function record( $test, ParserTestResult $result ) { $this->results[$test['desc']] = $result->isSuccess() ? 1 : 0; } - function report() { + public function report() { if ( $this->prevRun ) { // f = fail, p = pass, n = nonexistent // codes show before then after diff --git a/tests/parser/DbTestRecorder.php b/tests/parser/DbTestRecorder.php index 2089f64a02a8..d784ddd0afd4 100644 --- a/tests/parser/DbTestRecorder.php +++ b/tests/parser/DbTestRecorder.php @@ -34,7 +34,7 @@ class DbTestRecorder extends TestRecorder { * Set up result recording; insert a record for the run with the date * and all that fun stuff */ - function start() { + public function start() { $this->db->begin( __METHOD__ ); if ( !$this->db->tableExists( 'testrun' ) @@ -68,7 +68,7 @@ class DbTestRecorder extends TestRecorder { * @param array $test * @param ParserTestResult $result */ - function record( $test, ParserTestResult $result ) { + public function record( $test, ParserTestResult $result ) { $this->db->insert( 'testitem', [ 'ti_run' => $this->curRun, @@ -81,7 +81,7 @@ class DbTestRecorder extends TestRecorder { /** * Commit transaction and clean up for result recording */ - function end() { + public function end() { $this->db->commit( __METHOD__ ); } } diff --git a/tests/parser/ParserTestParserHook.php b/tests/parser/ParserTestParserHook.php index acc5cb158165..77fa7b4720a4 100644 --- a/tests/parser/ParserTestParserHook.php +++ b/tests/parser/ParserTestParserHook.php @@ -27,21 +27,21 @@ class ParserTestParserHook { - static function setup( &$parser ) { + public static function setup( &$parser ) { $parser->setHook( 'tag', [ __CLASS__, 'dumpHook' ] ); $parser->setHook( 'tåg', [ __CLASS__, 'dumpHook' ] ); $parser->setHook( 'statictag', [ __CLASS__, 'staticTagHook' ] ); return true; } - static function dumpHook( $in, $argv ) { + public static function dumpHook( $in, $argv ) { return "<pre>\n" . var_export( $in, true ) . "\n" . var_export( $argv, true ) . "\n" . "</pre>"; } - static function staticTagHook( $in, $argv, $parser ) { + public static function staticTagHook( $in, $argv, $parser ) { if ( !count( $argv ) ) { $parser->static_tag_buf = $in; return ''; diff --git a/tests/parser/ParserTestPrinter.php b/tests/parser/ParserTestPrinter.php index 34f8cd50d368..f3fa42d04acc 100644 --- a/tests/parser/ParserTestPrinter.php +++ b/tests/parser/ParserTestPrinter.php @@ -39,7 +39,7 @@ class ParserTestPrinter extends TestRecorder { private $markWhitespace; private $xmlError; - function __construct( $term, $options ) { + public function __construct( $term, $options ) { $this->term = $term; $options += [ 'showDiffs' => true, diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 91c3d40de933..65973881a1c1 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -797,7 +797,7 @@ class ParserTestRunner { * @param string|null $preprocessor * @return Parser */ - function getParser( $preprocessor = null ) { + public function getParser( $preprocessor = null ) { global $wgParserConf; $class = $wgParserConf['class']; diff --git a/tests/parser/editTests.php b/tests/parser/editTests.php index be4bcab3f46f..7abc6df385bd 100644 --- a/tests/parser/editTests.php +++ b/tests/parser/editTests.php @@ -17,7 +17,7 @@ class ParserEditTests extends Maintenance { private $numSkipped; private $numFailed; - function __construct() { + public function __construct() { parent::__construct(); $this->addOption( 'session-data', 'internal option, do not use', false, true ); $this->addOption( 'use-tidy-config', diff --git a/tests/parser/fuzzTest.php b/tests/parser/fuzzTest.php index eb4181c7e508..a7a8abf35d2d 100644 --- a/tests/parser/fuzzTest.php +++ b/tests/parser/fuzzTest.php @@ -13,7 +13,7 @@ class ParserFuzzTest extends Maintenance { private $memoryLimit = 100; private $seed; - function __construct() { + public function __construct() { parent::__construct(); $this->addDescription( 'Run a fuzz test on the parser, until it segfaults ' . 'or throws an exception' ); @@ -23,12 +23,12 @@ class ParserFuzzTest extends Maintenance { $this->addOption( 'seed', 'Start the fuzz test from the specified seed', false, true ); } - function finalSetup() { + public function finalSetup() { self::requireTestsAutoloader(); TestSetup::applyInitialConfig(); } - function execute() { + public function execute() { $files = $this->getOption( 'file', [ __DIR__ . '/parserTests.txt' ] ); $this->seed = intval( $this->getOption( 'seed', 1 ) ) - 1; $this->parserTest = new ParserTestRunner( @@ -42,7 +42,7 @@ class ParserFuzzTest extends Maintenance { * Draw input from a set of test files * @param array $filenames */ - function fuzzTest( $filenames ) { + public function fuzzTest( $filenames ) { $dict = $this->getFuzzInput( $filenames ); $dictSize = strlen( $dict ); $logMaxLength = log( $this->maxFuzzTestLength ); @@ -127,7 +127,7 @@ class ParserFuzzTest extends Maintenance { * Get a memory usage breakdown * @return array */ - function getMemoryBreakdown() { + private function getMemoryBreakdown() { $memStats = []; foreach ( $GLOBALS as $name => $value ) { @@ -162,7 +162,7 @@ class ParserFuzzTest extends Maintenance { /** * Estimate the size of the input variable */ - function guessVarSize( $var ) { + public function guessVarSize( $var ) { $length = 0; try { Wikimedia\suppressWarnings(); @@ -178,7 +178,7 @@ class ParserFuzzTest extends Maintenance { * @param array $filenames * @return string */ - function getFuzzInput( $filenames ) { + public function getFuzzInput( $filenames ) { $dict = ''; foreach ( $filenames as $filename ) { diff --git a/tests/parser/parserTests.php b/tests/parser/parserTests.php index 19d56844aefe..0713844ea0cd 100644 --- a/tests/parser/parserTests.php +++ b/tests/parser/parserTests.php @@ -33,7 +33,7 @@ require __DIR__ . '/../../maintenance/Maintenance.php'; use MediaWiki\MediaWikiServices; class ParserTestsMaintenance extends Maintenance { - function __construct() { + public function __construct() { parent::__construct(); $this->addDescription( 'Run parser tests' ); diff --git a/tests/phpunit/includes/ExtraParserTest.php b/tests/phpunit/includes/ExtraParserTest.php index fc317b719804..a4bd40755b27 100644 --- a/tests/phpunit/includes/ExtraParserTest.php +++ b/tests/phpunit/includes/ExtraParserTest.php @@ -201,7 +201,7 @@ class ExtraParserTest extends MediaWikiTestCase { * * @return array */ - static function statelessFetchTemplate( $title, $parser = false ) { + public static function statelessFetchTemplate( $title, $parser = false ) { $text = "Content of ''" . $title->getFullText() . "''"; $deps = []; diff --git a/tests/phpunit/includes/HooksTest.php b/tests/phpunit/includes/HooksTest.php index 217d51f15785..1558e5149951 100644 --- a/tests/phpunit/includes/HooksTest.php +++ b/tests/phpunit/includes/HooksTest.php @@ -4,7 +4,7 @@ use PHPUnit\Framework\Error\Deprecated; class HooksTest extends MediaWikiTestCase { - function setUp() { + public function setUp() { global $wgHooks; parent::setUp(); Hooks::clear( 'MediaWikiHooksTest001' ); diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 910621df2c65..fef4f0e8728a 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -939,7 +939,7 @@ class HtmlTest extends MediaWikiTestCase { } class HtmlTestValue { - function __toString() { + public function __toString() { return 'stringValue'; } } diff --git a/tests/phpunit/includes/LinkFilterTest.php b/tests/phpunit/includes/LinkFilterTest.php index 02fbd8193208..28ddc09bdd10 100644 --- a/tests/phpunit/includes/LinkFilterTest.php +++ b/tests/phpunit/includes/LinkFilterTest.php @@ -38,7 +38,7 @@ class LinkFilterTest extends MediaWikiLangTestCase { * @param array $like Array as created by LinkFilter::makeLikeArray() * @return string Regex */ - function createRegexFromLIKE( $like ) { + private function createRegexFromLIKE( $like ) { $regex = '!^'; foreach ( $like as $item ) { @@ -208,7 +208,7 @@ class LinkFilterTest extends MediaWikiLangTestCase { * - found: (bool) Should the URL be found? (defaults true) * - idn: (bool) Does this test require the idn conversion (default false) */ - function testMakeLikeArrayWithValidPatterns( $protocol, $pattern, $url, $options = [] ) { + public function testMakeLikeArrayWithValidPatterns( $protocol, $pattern, $url, $options = [] ) { $options += [ 'found' => true, 'idn' => false ]; if ( !empty( $options['idn'] ) && !LinkFilter::supportsIDN() ) { $this->markTestSkipped( 'LinkFilter IDN support is not available' ); @@ -281,7 +281,7 @@ class LinkFilterTest extends MediaWikiLangTestCase { * * @param string $pattern Invalid search pattern */ - function testMakeLikeArrayWithInvalidPatterns( $pattern ) { + public function testMakeLikeArrayWithInvalidPatterns( $pattern ) { $this->assertFalse( LinkFilter::makeLikeArray( $pattern ), "'$pattern' is not a valid pattern and should be rejected" diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index ba7c572ece14..64bb9ba2911b 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -962,7 +962,7 @@ class OutputPageTest extends MediaWikiTestCase { * @covers OutputPage::setArticleRelated * @covers OutputPage::isArticleRelated */ - function testArticleFlags() { + public function testArticleFlags() { $op = $this->newInstance(); $this->assertFalse( $op->isArticle() ); $this->assertTrue( $op->isArticleRelated() ); @@ -992,7 +992,7 @@ class OutputPageTest extends MediaWikiTestCase { * @covers OutputPage::addParserOutputMetadata * @covers OutputPage::addParserOutput */ - function testLanguageLinks() { + public function testLanguageLinks() { $op = $this->newInstance(); $this->assertSame( [], $op->getLanguageLinks() ); diff --git a/tests/phpunit/includes/Revision/MutableRevisionRecordTest.php b/tests/phpunit/includes/Revision/MutableRevisionRecordTest.php index 601f728d36e3..f0d25a6d7964 100644 --- a/tests/phpunit/includes/Revision/MutableRevisionRecordTest.php +++ b/tests/phpunit/includes/Revision/MutableRevisionRecordTest.php @@ -25,7 +25,7 @@ class MutableRevisionRecordTest extends MediaWikiTestCase { use RevisionRecordTests; - function setUp() { + public function setUp() { Title::clearCaches(); parent::setUp(); } diff --git a/tests/phpunit/includes/SiteStatsTest.php b/tests/phpunit/includes/SiteStatsTest.php index ff9fa7b34a09..d45ae2613ef7 100644 --- a/tests/phpunit/includes/SiteStatsTest.php +++ b/tests/phpunit/includes/SiteStatsTest.php @@ -5,7 +5,7 @@ class SiteStatsTest extends MediaWikiTestCase { /** * @covers SiteStats::jobs */ - function testJobsCountGetCached() { + public function testJobsCountGetCached() { $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ); $this->setService( 'MainWANObjectCache', $cache ); $jobq = JobQueueGroup::singleton(); diff --git a/tests/phpunit/includes/TitleMethodsTest.php b/tests/phpunit/includes/TitleMethodsTest.php index ad12f6228512..c36f8525dbd1 100644 --- a/tests/phpunit/includes/TitleMethodsTest.php +++ b/tests/phpunit/includes/TitleMethodsTest.php @@ -462,7 +462,7 @@ class TitleMethodsTest extends MediaWikiLangTestCase { ); } - function tearDown() { + public function tearDown() { Title::clearCaches(); parent::tearDown(); } diff --git a/tests/phpunit/includes/api/ApiUploadTestCase.php b/tests/phpunit/includes/api/ApiUploadTestCase.php index cf56052a55c8..5fb03175a5e1 100644 --- a/tests/phpunit/includes/api/ApiUploadTestCase.php +++ b/tests/phpunit/includes/api/ApiUploadTestCase.php @@ -94,7 +94,7 @@ abstract class ApiUploadTestCase extends ApiTestCase { * @throws Exception * @return bool */ - function fakeUploadFile( $fieldName, $fileName, $type, $filePath ) { + protected function fakeUploadFile( $fieldName, $fileName, $type, $filePath ) { $tmpName = $this->getNewTempFile(); if ( !file_exists( $filePath ) ) { throw new Exception( "$filePath doesn't exist!" ); @@ -121,7 +121,7 @@ abstract class ApiUploadTestCase extends ApiTestCase { return true; } - function fakeUploadChunk( $fieldName, $fileName, $type, & $chunkData ) { + public function fakeUploadChunk( $fieldName, $fileName, $type, & $chunkData ) { $tmpName = $this->getNewTempFile(); // copy the chunk data to temp location: if ( !file_put_contents( $tmpName, $chunkData ) ) { @@ -146,7 +146,7 @@ abstract class ApiUploadTestCase extends ApiTestCase { /** * Remove traces of previous fake uploads */ - function clearFakeUploads() { + public function clearFakeUploads() { $_FILES = []; } } diff --git a/tests/phpunit/includes/api/ApiWatchTest.php b/tests/phpunit/includes/api/ApiWatchTest.php index e76126fbb055..5356927badae 100644 --- a/tests/phpunit/includes/api/ApiWatchTest.php +++ b/tests/phpunit/includes/api/ApiWatchTest.php @@ -9,7 +9,7 @@ * @covers ApiWatch */ class ApiWatchTest extends ApiTestCase { - function getTokens() { + protected function getTokens() { return $this->getTokenList( self::$users['sysop'] ); } diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php index 41cd039d3da5..ada102c53c5d 100644 --- a/tests/phpunit/includes/api/RandomImageGenerator.php +++ b/tests/phpunit/includes/api/RandomImageGenerator.php @@ -110,7 +110,7 @@ class RandomImageGenerator { * @param string|null $dir Directory, optional (will default to current working directory) * @return array Filenames we just wrote */ - function writeImages( $number, $format = 'jpg', $dir = null ) { + public function writeImages( $number, $format = 'jpg', $dir = null ) { $filenames = $this->getRandomFilenames( $number, $format, $dir ); $imageWriteMethod = $this->getImageWriteMethod( $format ); foreach ( $filenames as $filename ) { @@ -128,7 +128,7 @@ class RandomImageGenerator { * @throws Exception * @return string */ - function getImageWriteMethod( $format ) { + public function getImageWriteMethod( $format ) { global $wgUseImageMagick, $wgImageMagickConvertCommand; if ( $format === 'svg' ) { return 'writeSvg'; @@ -226,7 +226,7 @@ class RandomImageGenerator { * @param array $shape Array of arrays, each array containing x & y keys mapped to numeric values * @return string */ - static function shapePointsToString( $shape ) { + public static function shapePointsToString( $shape ) { $points = []; foreach ( $shape as $point ) { $points[] = $point['x'] . ',' . $point['y']; diff --git a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php index c935c2de8830..0f47d7055a1c 100644 --- a/tests/phpunit/includes/api/query/ApiQueryBasicTest.php +++ b/tests/phpunit/includes/api/query/ApiQueryBasicTest.php @@ -36,7 +36,7 @@ class ApiQueryBasicTest extends ApiQueryTestBase { * * @see MediaWikiTestCase::addDBDataOnce() */ - function addDBDataOnce() { + public function addDBDataOnce() { try { if ( Title::newFromText( 'AQBT-All' )->exists() ) { return; diff --git a/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php b/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php index a1aeb6637785..db4ff85555e0 100644 --- a/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php +++ b/tests/phpunit/includes/api/query/ApiQueryContinue2Test.php @@ -32,7 +32,7 @@ class ApiQueryContinue2Test extends ApiQueryContinueTestBase { * * @see MediaWikiTestCase::addDBDataOnce() */ - function addDBDataOnce() { + public function addDBDataOnce() { try { $this->editPage( 'AQCT73462-A', '**AQCT73462-A** [[AQCT73462-B]] [[AQCT73462-C]]' ); $this->editPage( 'AQCT73462-B', '[[AQCT73462-A]] **AQCT73462-B** [[AQCT73462-C]]' ); diff --git a/tests/phpunit/includes/api/query/ApiQueryContinueTest.php b/tests/phpunit/includes/api/query/ApiQueryContinueTest.php index a12d9b0f4311..4358191f7b31 100644 --- a/tests/phpunit/includes/api/query/ApiQueryContinueTest.php +++ b/tests/phpunit/includes/api/query/ApiQueryContinueTest.php @@ -36,7 +36,7 @@ class ApiQueryContinueTest extends ApiQueryContinueTestBase { * * @see MediaWikiTestCase::addDBDataOnce() */ - function addDBDataOnce() { + public function addDBDataOnce() { try { $this->editPage( 'Template:AQCT-T1', '**Template:AQCT-T1**' ); $this->editPage( 'Template:AQCT-T2', '**Template:AQCT-T2**' ); diff --git a/tests/phpunit/includes/api/query/ApiQueryTest.php b/tests/phpunit/includes/api/query/ApiQueryTest.php index 20bd8557d067..9ed37542ade0 100644 --- a/tests/phpunit/includes/api/query/ApiQueryTest.php +++ b/tests/phpunit/includes/api/query/ApiQueryTest.php @@ -102,7 +102,7 @@ class ApiQueryTest extends ApiTestCase { * @param string $expectException * @dataProvider provideTestTitlePartToKey */ - function testTitlePartToKey( $titlePart, $namespace, $expected, $expectException ) { + public function testTitlePartToKey( $titlePart, $namespace, $expected, $expectException ) { $this->setMwGlobals( [ 'wgCapitalLinks' => true, ] ); @@ -118,7 +118,7 @@ class ApiQueryTest extends ApiTestCase { 'ApiUsageException thrown by titlePartToKey' ); } - function provideTestTitlePartToKey() { + public function provideTestTitlePartToKey() { return [ [ 'a b c', NS_MAIN, 'A_b_c', false ], [ 'x', NS_MAIN, 'X', false ], diff --git a/tests/phpunit/includes/block/DatabaseBlockTest.php b/tests/phpunit/includes/block/DatabaseBlockTest.php index 9182609ff794..cfab9e5e4e65 100644 --- a/tests/phpunit/includes/block/DatabaseBlockTest.php +++ b/tests/phpunit/includes/block/DatabaseBlockTest.php @@ -160,7 +160,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase { } } - function provideNewFromTargetRangeBlocks() { + public function provideNewFromTargetRangeBlocks() { return [ 'Blocks to IPv4 ranges' => [ [ '0.0.0.0/20', '0.0.0.0/30', '0.0.0.0/25' ], diff --git a/tests/phpunit/includes/cache/GenderCacheTest.php b/tests/phpunit/includes/cache/GenderCacheTest.php index fbce1619dc22..feb762d374e0 100644 --- a/tests/phpunit/includes/cache/GenderCacheTest.php +++ b/tests/phpunit/includes/cache/GenderCacheTest.php @@ -11,7 +11,7 @@ class GenderCacheTest extends MediaWikiLangTestCase { /** @var string[] User key => username */ private static $nameMap; - function addDBDataOnce() { + public function addDBDataOnce() { // ensure the correct default gender $this->mergeMwGlobalArrayValue( 'wgDefaultUserOptions', [ 'gender' => 'unknown' ] ); diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php index 869236b43fa1..e786f42ae970 100644 --- a/tests/phpunit/includes/cache/MessageCacheTest.php +++ b/tests/phpunit/includes/cache/MessageCacheTest.php @@ -26,7 +26,7 @@ class MessageCacheTest extends MediaWikiLangTestCase { $this->setContentLang( 'de' ); } - function addDBDataOnce() { + public function addDBDataOnce() { $this->configureLanguages(); // Set up messages and fallbacks ab -> ru -> de @@ -89,7 +89,7 @@ class MessageCacheTest extends MediaWikiLangTestCase { $this->assertEquals( $expectedContent, $result, "Message fallback failed." ); } - function provideMessagesForFallback() { + public function provideMessagesForFallback() { return [ [ 'FallbackLanguageTest-Full', 'ab', 'ab' ], [ 'FallbackLanguageTest-Partial', 'ab', 'ru' ], diff --git a/tests/phpunit/includes/collation/CollationTest.php b/tests/phpunit/includes/collation/CollationTest.php index b92e651e2b50..e97f14a5107a 100644 --- a/tests/phpunit/includes/collation/CollationTest.php +++ b/tests/phpunit/includes/collation/CollationTest.php @@ -92,7 +92,7 @@ class CollationTest extends MediaWikiLangTestCase { $this->assertEquals( $firstLetter, $col->getFirstLetter( $string ) ); } - function firstLetterProvider() { + public function firstLetterProvider() { return [ [ 'uppercase', 'Abc', 'A' ], [ 'uppercase', 'abc', 'A' ], diff --git a/tests/phpunit/includes/db/DatabaseTestHelper.php b/tests/phpunit/includes/db/DatabaseTestHelper.php index f037a8cba38b..ec4d67bcf2e0 100644 --- a/tests/phpunit/includes/db/DatabaseTestHelper.php +++ b/tests/phpunit/includes/db/DatabaseTestHelper.php @@ -136,7 +136,7 @@ class DatabaseTestHelper extends Database { } } - function strencode( $s ) { + public function strencode( $s ) { // Choose apos to avoid handling of escaping double quotes in quoted text return str_replace( "'", "\'", $s ); } @@ -168,49 +168,49 @@ class DatabaseTestHelper extends Database { parent::nativeReplace( $table, $rows, $fname ); } - function getType() { + public function getType() { return 'test'; } - function open( $server, $user, $password, $dbName, $schema, $tablePrefix ) { + public function open( $server, $user, $password, $dbName, $schema, $tablePrefix ) { $this->conn = (object)[ 'test' ]; return true; } - function fetchObject( $res ) { + public function fetchObject( $res ) { return false; } - function fetchRow( $res ) { + public function fetchRow( $res ) { return false; } - function numRows( $res ) { + public function numRows( $res ) { return -1; } - function numFields( $res ) { + public function numFields( $res ) { return -1; } - function fieldName( $res, $n ) { + public function fieldName( $res, $n ) { return 'test'; } - function insertId() { + public function insertId() { return -1; } - function dataSeek( $res, $row ) { + public function dataSeek( $res, $row ) { /* nop */ } - function lastErrno() { + public function lastErrno() { return $this->lastError ? $this->lastError['errno'] : -1; } - function lastError() { + public function lastError() { return $this->lastError ? $this->lastError['error'] : 'test'; } @@ -218,31 +218,31 @@ class DatabaseTestHelper extends Database { return $this->lastError['wasKnownStatementRollbackError'] ?? false; } - function fieldInfo( $table, $field ) { + public function fieldInfo( $table, $field ) { return false; } - function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) { + public function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) { return false; } - function fetchAffectedRowCount() { + public function fetchAffectedRowCount() { return -1; } - function getSoftwareLink() { + public function getSoftwareLink() { return 'test'; } - function getServerVersion() { + public function getServerVersion() { return 'test'; } - function getServerInfo() { + public function getServerInfo() { return 'test'; } - function ping( &$rtt = null ) { + public function ping( &$rtt = null ) { $rtt = 0.0; return true; } diff --git a/tests/phpunit/includes/db/LoadBalancerTest.php b/tests/phpunit/includes/db/LoadBalancerTest.php index 282c995dcb54..1fbb836ae0c7 100644 --- a/tests/phpunit/includes/db/LoadBalancerTest.php +++ b/tests/phpunit/includes/db/LoadBalancerTest.php @@ -431,7 +431,7 @@ class LoadBalancerTest extends MediaWikiTestCase { * @covers \Wikimedia\Rdbms\LoadBalancer::getAnyOpenConnection() * @covers \Wikimedia\Rdbms\LoadBalancer::getWriterIndex() */ - function testOpenConnection() { + public function testOpenConnection() { $lb = $this->newSingleServerLocalLoadBalancer(); $i = $lb->getWriterIndex(); diff --git a/tests/phpunit/includes/deferred/LinksUpdateTest.php b/tests/phpunit/includes/deferred/LinksUpdateTest.php index 1f9d29e26c3e..6ae510aa3188 100644 --- a/tests/phpunit/includes/deferred/LinksUpdateTest.php +++ b/tests/phpunit/includes/deferred/LinksUpdateTest.php @@ -9,7 +9,7 @@ class LinksUpdateTest extends MediaWikiLangTestCase { protected static $testingPageId; - function __construct( $name = null, array $data = [], $dataName = '' ) { + public function __construct( $name = null, array $data = [], $dataName = '' ) { parent::__construct( $name, $data, $dataName ); $this->tablesUsed = array_merge( $this->tablesUsed, diff --git a/tests/phpunit/includes/filebackend/FileBackendTest.php b/tests/phpunit/includes/filebackend/FileBackendTest.php index 9d0a37af5bd7..2d9f23e0aeaf 100644 --- a/tests/phpunit/includes/filebackend/FileBackendTest.php +++ b/tests/phpunit/includes/filebackend/FileBackendTest.php @@ -1023,7 +1023,7 @@ class FileBackendTest extends MediaWikiTestCase { } } - function provider_quickOperations() { + public function provider_quickOperations() { $base = self::baseStorePath(); $files = [ "$base/unittest-cont1/e/fileA.a", @@ -2730,7 +2730,7 @@ class FileBackendTest extends MediaWikiTestCase { return $this->backend->doQuickOperations( [ $params ] ); } - function tearDownFiles() { + public function tearDownFiles() { $containers = [ 'unittest-cont1', 'unittest-cont2' ]; foreach ( $containers as $container ) { $this->deleteFiles( $container ); diff --git a/tests/phpunit/includes/filerepo/RepoGroupTest.php b/tests/phpunit/includes/filerepo/RepoGroupTest.php index 04452f2259ae..5338b795a572 100644 --- a/tests/phpunit/includes/filerepo/RepoGroupTest.php +++ b/tests/phpunit/includes/filerepo/RepoGroupTest.php @@ -5,18 +5,18 @@ */ class RepoGroupTest extends MediaWikiTestCase { - function testHasForeignRepoNegative() { + public function testHasForeignRepoNegative() { $this->setMwGlobals( 'wgForeignFileRepos', [] ); FileBackendGroup::destroySingleton(); $this->assertFalse( RepoGroup::singleton()->hasForeignRepos() ); } - function testHasForeignRepoPositive() { + public function testHasForeignRepoPositive() { $this->setUpForeignRepo(); $this->assertTrue( RepoGroup::singleton()->hasForeignRepos() ); } - function testForEachForeignRepo() { + public function testForEachForeignRepo() { $this->setUpForeignRepo(); $fakeCallback = $this->createMock( RepoGroupTestHelper::class ); $fakeCallback->expects( $this->once() )->method( 'callback' ); @@ -24,7 +24,7 @@ class RepoGroupTest extends MediaWikiTestCase { [ $fakeCallback, 'callback' ], [ [] ] ); } - function testForEachForeignRepoNone() { + public function testForEachForeignRepoNone() { $this->setMwGlobals( 'wgForeignFileRepos', [] ); FileBackendGroup::destroySingleton(); $fakeCallback = $this->createMock( RepoGroupTestHelper::class ); @@ -54,7 +54,7 @@ class RepoGroupTest extends MediaWikiTestCase { * Quick helper class to use as a mock callback for RepoGroup::singleton()->forEachForeignRepo. */ class RepoGroupTestHelper { - function callback( FileRepo $repo, array $foo ) { + public function callback( FileRepo $repo, array $foo ) { return true; } } diff --git a/tests/phpunit/includes/filerepo/file/FileTest.php b/tests/phpunit/includes/filerepo/file/FileTest.php index 3f4e46b5b0ce..23b614910b09 100644 --- a/tests/phpunit/includes/filerepo/file/FileTest.php +++ b/tests/phpunit/includes/filerepo/file/FileTest.php @@ -8,13 +8,13 @@ class FileTest extends MediaWikiMediaTestCase { * @dataProvider providerCanAnimate * @covers File::canAnimateThumbIfAppropriate */ - function testCanAnimateThumbIfAppropriate( $filename, $expected ) { + public function testCanAnimateThumbIfAppropriate( $filename, $expected ) { $this->setMwGlobals( 'wgMaxAnimatedGifArea', 9000 ); $file = $this->dataFile( $filename ); $this->assertEquals( $file->canAnimateThumbIfAppropriate(), $expected ); } - function providerCanAnimate() { + public function providerCanAnimate() { return [ [ 'nonanimated.gif', true ], [ 'jpeg-comment-utf.jpg', true ], diff --git a/tests/phpunit/includes/htmlform/HTMLAutoCompleteSelectFieldTest.php b/tests/phpunit/includes/htmlform/HTMLAutoCompleteSelectFieldTest.php index eaba22d7fb61..9e96e186d308 100644 --- a/tests/phpunit/includes/htmlform/HTMLAutoCompleteSelectFieldTest.php +++ b/tests/phpunit/includes/htmlform/HTMLAutoCompleteSelectFieldTest.php @@ -18,7 +18,7 @@ class HTMLAutoCompleteSelectFieldTest extends MediaWikiTestCase { * @expectedException MWException * @expectedExceptionMessage called without any autocompletions */ - function testMissingAutocompletions() { + public function testMissingAutocompletions() { new HTMLAutoCompleteSelectField( [ 'fieldname' => 'Test' ] ); } @@ -28,7 +28,7 @@ class HTMLAutoCompleteSelectFieldTest extends MediaWikiTestCase { * * @covers HTMLAutoCompleteSelectField::getAttributes */ - function testGetAttributes() { + public function testGetAttributes() { $field = new HTMLAutoCompleteSelectField( [ 'fieldname' => 'Test', 'autocomplete' => $this->options, @@ -45,7 +45,7 @@ class HTMLAutoCompleteSelectFieldTest extends MediaWikiTestCase { * Test that the optional select dropdown is included or excluded based on * the presence or absence of the 'options' parameter. */ - function testOptionalSelectElement() { + public function testOptionalSelectElement() { $params = [ 'fieldname' => 'Test', 'autocomplete-data' => $this->options, diff --git a/tests/phpunit/includes/jobqueue/JobQueueTest.php b/tests/phpunit/includes/jobqueue/JobQueueTest.php index 1db708540fa5..fd73f8b2cdc9 100644 --- a/tests/phpunit/includes/jobqueue/JobQueueTest.php +++ b/tests/phpunit/includes/jobqueue/JobQueueTest.php @@ -11,7 +11,7 @@ class JobQueueTest extends MediaWikiTestCase { protected $key; protected $queueRand, $queueRandTTL, $queueFifo, $queueFifoTTL; - function __construct( $name = null, array $data = [], $dataName = '' ) { + public function __construct( $name = null, array $data = [], $dataName = '' ) { parent::__construct( $name, $data, $dataName ); $this->tablesUsed[] = 'job'; @@ -378,12 +378,12 @@ class JobQueueTest extends MediaWikiTestCase { ]; } - function newJob( $i = 0, $rootJob = [] ) { + protected function newJob( $i = 0, $rootJob = [] ) { return Job::factory( 'null', Title::newMainPage(), [ 'lives' => 0, 'usleep' => 0, 'removeDuplicates' => 0, 'i' => $i ] + $rootJob ); } - function newDedupedJob( $i = 0, $rootJob = [] ) { + protected function newDedupedJob( $i = 0, $rootJob = [] ) { return Job::factory( 'null', Title::newMainPage(), [ 'lives' => 0, 'usleep' => 0, 'removeDuplicates' => 1, 'i' => $i ] + $rootJob ); } diff --git a/tests/phpunit/includes/libs/ArrayUtilsTest.php b/tests/phpunit/includes/libs/ArrayUtilsTest.php index 12b632056475..48bc584f4db2 100644 --- a/tests/phpunit/includes/libs/ArrayUtilsTest.php +++ b/tests/phpunit/includes/libs/ArrayUtilsTest.php @@ -12,7 +12,7 @@ class ArrayUtilsTest extends PHPUnit\Framework\TestCase { * @covers ArrayUtils::findLowerBound * @dataProvider provideFindLowerBound */ - function testFindLowerBound( + public function testFindLowerBound( $valueCallback, $valueCount, $comparisonCallback, $target, $expected ) { $this->assertSame( @@ -22,7 +22,7 @@ class ArrayUtilsTest extends PHPUnit\Framework\TestCase { ); } - function provideFindLowerBound() { + public function provideFindLowerBound() { $indexValueCallback = function ( $size ) { return function ( $val ) use ( $size ) { $this->assertTrue( $val >= 0 ); @@ -133,13 +133,13 @@ class ArrayUtilsTest extends PHPUnit\Framework\TestCase { * @covers ArrayUtils::arrayDiffAssocRecursive * @dataProvider provideArrayDiffAssocRecursive */ - function testArrayDiffAssocRecursive( $expected, ...$args ) { + public function testArrayDiffAssocRecursive( $expected, ...$args ) { $this->assertEquals( call_user_func_array( 'ArrayUtils::arrayDiffAssocRecursive', $args ), $expected ); } - function provideArrayDiffAssocRecursive() { + public function provideArrayDiffAssocRecursive() { return [ [ [], diff --git a/tests/phpunit/includes/libs/MapCacheLRUTest.php b/tests/phpunit/includes/libs/MapCacheLRUTest.php index 0c8dc689868f..00b97a8f9d12 100644 --- a/tests/phpunit/includes/libs/MapCacheLRUTest.php +++ b/tests/phpunit/includes/libs/MapCacheLRUTest.php @@ -14,7 +14,7 @@ class MapCacheLRUTest extends PHPUnit\Framework\TestCase { * @covers MapCacheLRU::getMaxSize() * @covers MapCacheLRU::setMaxSize() */ - function testArrayConversion() { + public function testArrayConversion() { $raw = [ 'd' => 4, 'c' => 3, 'b' => 2, 'a' => 1 ]; $cache = MapCacheLRU::newFromArray( $raw, 3 ); @@ -59,7 +59,7 @@ class MapCacheLRUTest extends PHPUnit\Framework\TestCase { * @covers MapCacheLRU::serialize() * @covers MapCacheLRU::unserialize() */ - function testSerialize() { + public function testSerialize() { $cache = MapCacheLRU::newFromArray( [ 'd' => 4, 'c' => 3, 'b' => 2, 'a' => 1 ], 10 ); $string = serialize( $cache ); $ncache = unserialize( $string ); @@ -74,7 +74,7 @@ class MapCacheLRUTest extends PHPUnit\Framework\TestCase { * @covers MapCacheLRU::get() * @covers MapCacheLRU::set() */ - function testMissing() { + public function testMissing() { $raw = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; $cache = MapCacheLRU::newFromArray( $raw, 3 ); @@ -89,7 +89,7 @@ class MapCacheLRUTest extends PHPUnit\Framework\TestCase { * @covers MapCacheLRU::get() * @covers MapCacheLRU::set() */ - function testLRU() { + public function testLRU() { $raw = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; $cache = MapCacheLRU::newFromArray( $raw, 3 ); diff --git a/tests/phpunit/includes/libs/StringUtilsTest.php b/tests/phpunit/includes/libs/StringUtilsTest.php index 66b04adacbcd..93b4c8f2940d 100644 --- a/tests/phpunit/includes/libs/StringUtilsTest.php +++ b/tests/phpunit/includes/libs/StringUtilsTest.php @@ -18,7 +18,7 @@ class StringUtilsTest extends PHPUnit\Framework\TestCase { * @param string $string * @return string */ - function escaped( $string ) { + private function escaped( $string ) { $escaped = ''; $length = strlen( $string ); for ( $i = 0; $i < $length; $i++ ) { diff --git a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php index 51ad915d44ec..ec6d1404e69c 100644 --- a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php +++ b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php @@ -10,7 +10,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** @var MimeAnalyzer */ private $mimeAnalyzer; - function setUp() { + public function setUp() { global $IP; $this->mimeAnalyzer = new MimeAnalyzer( [ @@ -27,7 +27,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { parent::setUp(); } - function doGuessMimeType( array $parameters = [] ) { + private function doGuessMimeType( array $parameters = [] ) { $class = new ReflectionClass( get_class( $this->mimeAnalyzer ) ); $method = $class->getMethod( 'doGuessMimeType' ); $method->setAccessible( true ); @@ -40,12 +40,12 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * @param string $oldMime Initially detected MIME * @param string $expectedMime MIME type after taking extension into account */ - function testImproveTypeFromExtension( $ext, $oldMime, $expectedMime ) { + public function testImproveTypeFromExtension( $ext, $oldMime, $expectedMime ) { $actualMime = $this->mimeAnalyzer->improveTypeFromExtension( $oldMime, $ext ); $this->assertEquals( $expectedMime, $actualMime ); } - function providerImproveTypeFromExtension() { + public function providerImproveTypeFromExtension() { return [ [ 'gif', 'image/gif', 'image/gif' ], [ 'gif', 'unknown/unknown', 'unknown/unknown' ], @@ -68,7 +68,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that encoder=ffmpeg2theora doesn't trigger * MEDIATYPE_VIDEO (T65584) */ - function testOggRecognize() { + public function testOggRecognize() { $oggFile = __DIR__ . '/../../../data/media/say-test.ogg'; $actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 'application/ogg' ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); @@ -78,7 +78,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * Test to make sure that Opus audio files don't trigger * MEDIATYPE_MULTIMEDIA (bug T151352) */ - function testOpusRecognize() { + public function testOpusRecognize() { $oggFile = __DIR__ . '/../../../data/media/say-test.opus'; $actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 'application/ogg' ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); @@ -87,7 +87,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** * Test to make sure that mp3 files are detected as audio type */ - function testMP3AsAudio() { + public function testMP3AsAudio() { $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3'; $actualType = $this->mimeAnalyzer->getMediaType( $file ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); @@ -96,7 +96,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** * Test to make sure that MP3 with id3 tag is recognized */ - function testMP3WithID3Recognize() { + public function testMP3WithID3Recognize() { $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); @@ -105,7 +105,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** * Test to make sure that MP3 without id3 tag is recognized (MPEG-1 sample rates) */ - function testMP3NoID3RecognizeMPEG1() { + public function testMP3NoID3RecognizeMPEG1() { $file = __DIR__ . '/../../../data/media/say-test-mpeg1.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); @@ -114,7 +114,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** * Test to make sure that MP3 without id3 tag is recognized (MPEG-2 sample rates) */ - function testMP3NoID3RecognizeMPEG2() { + public function testMP3NoID3RecognizeMPEG2() { $file = __DIR__ . '/../../../data/media/say-test-mpeg2.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); @@ -123,7 +123,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** * Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 sample rates) */ - function testMP3NoID3RecognizeMPEG2_5() { + public function testMP3NoID3RecognizeMPEG2_5() { $file = __DIR__ . '/../../../data/media/say-test-mpeg2.5.mp3'; $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); $this->assertEquals( 'audio/mpeg', $actualType ); @@ -132,7 +132,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { /** * A ZIP file embedded in the middle of a .doc file is still a Word Document. */ - function testZipInDoc() { + public function testZipInDoc() { $file = __DIR__ . '/../../../data/media/zip-in-doc.doc'; $actualType = $this->doGuessMimeType( [ $file, 'doc' ] ); $this->assertEquals( 'application/msword', $actualType ); @@ -142,7 +142,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * @covers MimeAnalyzer::detectZipType * @dataProvider provideOpendocumentsformatHeaders */ - function testDetectZipTypeRecognizesOpendocuments( $expected, $header ) { + public function testDetectZipTypeRecognizesOpendocuments( $expected, $header ) { $this->assertEquals( $expected, $this->mimeAnalyzer->detectZipType( $header ) @@ -153,7 +153,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { * An ODF file is a ZIP file of multiple files. The first one being * 'mimetype' and is not compressed. */ - function provideOpendocumentsformatHeaders() { + public function provideOpendocumentsformatHeaders() { $thirtychars = str_repeat( 0, 30 ); return [ 'Database front end document header based on ODF 1.2' => [ @@ -163,7 +163,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { ]; } - function providePngZipConfusion() { + public function providePngZipConfusion() { return [ [ 'An invalid ZIP file due to the signature being too close to the ' . @@ -194,7 +194,7 @@ class MimeAnalyzerTest extends PHPUnit\Framework\TestCase { } /** @dataProvider providePngZipConfusion */ - function testPngZipConfusion( $description, $fileName, $expectedType ) { + public function testPngZipConfusion( $description, $fileName, $expectedType ) { $file = __DIR__ . '/../../../data/media/' . $fileName; $actualType = $this->doGuessMimeType( [ $file, 'png' ] ); $this->assertEquals( $expectedType, $actualType, $description ); diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index e47c7b1c852d..e2ead3695a87 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -487,7 +487,7 @@ class WANObjectCacheTest extends PHPUnit\Framework\TestCase { * @param array $extOpts * @param bool $versioned */ - function testGetWithSetcallback_touched( array $extOpts, $versioned ) { + public function testGetWithSetcallback_touched( array $extOpts, $versioned ) { $cache = $this->cache; $mockWallClock = 1549343530.2053; diff --git a/tests/phpunit/includes/libs/rdbms/database/DBConnRefTest.php b/tests/phpunit/includes/libs/rdbms/database/DBConnRefTest.php index 393265a50c4a..5a686d1ce209 100644 --- a/tests/phpunit/includes/libs/rdbms/database/DBConnRefTest.php +++ b/tests/phpunit/includes/libs/rdbms/database/DBConnRefTest.php @@ -200,7 +200,7 @@ class DBConnRefTest extends PHPUnit\Framework\TestCase { $ref->$method( ...$args ); } - function provideRoleExceptions() { + public function provideRoleExceptions() { return [ [ 'insert', [ 'table', [ 'a' => 1 ] ] ], [ 'update', [ 'table', [ 'a' => 1 ], [ 'a' => 2 ] ] ], diff --git a/tests/phpunit/includes/linker/LinkRendererTest.php b/tests/phpunit/includes/linker/LinkRendererTest.php index d176e3914500..d359988a67b5 100644 --- a/tests/phpunit/includes/linker/LinkRendererTest.php +++ b/tests/phpunit/includes/linker/LinkRendererTest.php @@ -192,7 +192,7 @@ class LinkRendererTest extends MediaWikiLangTestCase { ); } - function tearDown() { + public function tearDown() { Title::clearCaches(); parent::tearDown(); } diff --git a/tests/phpunit/includes/media/SVGReaderTest.php b/tests/phpunit/includes/media/SVGReaderTest.php index 7063a575da07..ed0fa16f5f5c 100644 --- a/tests/phpunit/includes/media/SVGReaderTest.php +++ b/tests/phpunit/includes/media/SVGReaderTest.php @@ -32,7 +32,7 @@ class SVGReaderTest extends \MediaWikiIntegrationTestCase { ); } - function assertMetadata( $infile, $expected ) { + private function assertMetadata( $infile, $expected ) { try { $svgReader = new SVGReader( $infile ); $data = $svgReader->getMetadata(); diff --git a/tests/phpunit/includes/page/ImagePage404Test.php b/tests/phpunit/includes/page/ImagePage404Test.php index 4faace2160f1..dccc2ebc5d8b 100644 --- a/tests/phpunit/includes/page/ImagePage404Test.php +++ b/tests/phpunit/includes/page/ImagePage404Test.php @@ -8,7 +8,7 @@ class ImagePage404Test extends MediaWikiMediaTestCase { return parent::getRepoOptions() + [ 'transformVia404' => true ]; } - function setUp() { + public function setUp() { $this->setMwGlobals( 'wgImageLimits', [ [ 320, 240 ], [ 640, 480 ], @@ -19,7 +19,7 @@ class ImagePage404Test extends MediaWikiMediaTestCase { parent::setUp(); } - function getImagePage( $filename ) { + private function getImagePage( $filename ) { $title = Title::makeTitleSafe( NS_FILE, $filename ); $file = $this->dataFile( $filename ); $iPage = new ImagePage( $title ); @@ -33,7 +33,7 @@ class ImagePage404Test extends MediaWikiMediaTestCase { * @param string $filename * @param int $expectedNumberThumbs How many thumbnails to show */ - function testGetThumbSizes( $filename, $expectedNumberThumbs ) { + public function testGetThumbSizes( $filename, $expectedNumberThumbs ) { $iPage = $this->getImagePage( $filename ); $reflection = new ReflectionClass( $iPage ); $reflMethod = $reflection->getMethod( 'getThumbSizes' ); @@ -43,7 +43,7 @@ class ImagePage404Test extends MediaWikiMediaTestCase { $this->assertEquals( count( $actual ), $expectedNumberThumbs ); } - function providerGetThumbSizes() { + public function providerGetThumbSizes() { return [ [ 'animated.gif', 6 ], [ 'Toll_Texas_1.svg', 6 ], diff --git a/tests/phpunit/includes/page/PageArchiveTestBase.php b/tests/phpunit/includes/page/PageArchiveTestBase.php index 90b118c40e73..b380c7e1a5aa 100644 --- a/tests/phpunit/includes/page/PageArchiveTestBase.php +++ b/tests/phpunit/includes/page/PageArchiveTestBase.php @@ -36,7 +36,7 @@ abstract class PageArchiveTestBase extends MediaWikiTestCase { */ protected $ipRev; - function __construct( $name = null, array $data = [], $dataName = '' ) { + public function __construct( $name = null, array $data = [], $dataName = '' ) { parent::__construct( $name, $data, $dataName ); $this->tablesUsed = array_merge( diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php index 3b2b1050bd17..d44123ee2c11 100644 --- a/tests/phpunit/includes/parser/PreprocessorTest.php +++ b/tests/phpunit/includes/parser/PreprocessorTest.php @@ -57,7 +57,7 @@ class PreprocessorTest extends MediaWikiTestCase { } } - function getStripList() { + public function getStripList() { return [ 'gallery', 'display map' /* Used by Maps, see r80025 CR */, '/foo' ]; } diff --git a/tests/phpunit/includes/parser/SanitizerTest.php b/tests/phpunit/includes/parser/SanitizerTest.php index 99e8fb7ebd6a..3b88b163c467 100644 --- a/tests/phpunit/includes/parser/SanitizerTest.php +++ b/tests/phpunit/includes/parser/SanitizerTest.php @@ -49,7 +49,7 @@ class SanitizerTest extends MediaWikiTestCase { ]; } - function dataRemoveHTMLtags() { + public function dataRemoveHTMLtags() { return [ // former testSelfClosingTag [ diff --git a/tests/phpunit/includes/parser/TagHooksTest.php b/tests/phpunit/includes/parser/TagHooksTest.php index 06da7a53f709..0b0720a160b7 100644 --- a/tests/phpunit/includes/parser/TagHooksTest.php +++ b/tests/phpunit/includes/parser/TagHooksTest.php @@ -122,11 +122,11 @@ class TagHooksTest extends MediaWikiTestCase { $this->fail( 'Exception not thrown.' ); } - function tagCallback( $text, $params, $parser ) { + public function tagCallback( $text, $params, $parser ) { return str_rot13( $text ); } - function functionTagCallback( &$parser, $frame, $code, $attribs ) { + public function functionTagCallback( &$parser, $frame, $code, $attribs ) { return str_rot13( $code ); } } diff --git a/tests/phpunit/includes/search/SearchNearMatcherTest.php b/tests/phpunit/includes/search/SearchNearMatcherTest.php index 9ccae8cc95e7..afd367a90865 100644 --- a/tests/phpunit/includes/search/SearchNearMatcherTest.php +++ b/tests/phpunit/includes/search/SearchNearMatcherTest.php @@ -28,7 +28,7 @@ class SearchNearMatcherTest extends \PHPUnit\Framework\TestCase { $this->assertEquals( $expected, $title === null ? null : (string)$title ); } - function tearDown() { + public function tearDown() { Title::clearCaches(); parent::tearDown(); } diff --git a/tests/phpunit/includes/specials/ContribsPagerTest.php b/tests/phpunit/includes/specials/ContribsPagerTest.php index 338a86ed58a8..1993250cfd62 100644 --- a/tests/phpunit/includes/specials/ContribsPagerTest.php +++ b/tests/phpunit/includes/specials/ContribsPagerTest.php @@ -13,7 +13,7 @@ class ContribsPagerTest extends MediaWikiTestCase { /** @var LinkRenderer */ private $linkRenderer; - function setUp() { + public function setUp() { $this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); $context = new RequestContext(); $this->pager = new ContribsPager( $context, [ diff --git a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php index a95d43c002ca..2b2eec9122f5 100644 --- a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php +++ b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php @@ -38,7 +38,7 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase { /** * Initialize all query page objects */ - function __construct() { + public function __construct() { parent::__construct(); foreach ( QueryPage::getPages() as $page ) { diff --git a/tests/phpunit/includes/specials/SpecialMIMESearchTest.php b/tests/phpunit/includes/specials/SpecialMIMESearchTest.php index 08225a697db3..499288e9f3ca 100644 --- a/tests/phpunit/includes/specials/SpecialMIMESearchTest.php +++ b/tests/phpunit/includes/specials/SpecialMIMESearchTest.php @@ -9,7 +9,7 @@ class SpecialMIMESearchTest extends MediaWikiTestCase { /** @var SpecialMIMESearch */ private $page; - function setUp() { + public function setUp() { $this->page = new SpecialMIMESearch; $context = new RequestContext(); $context->setTitle( Title::makeTitle( NS_SPECIAL, 'MIMESearch' ) ); @@ -25,7 +25,7 @@ class SpecialMIMESearchTest extends MediaWikiTestCase { * @param string $major Major MIME type we expect to look for * @param string $minor Minor MIME type we expect to look for */ - function testMimeFiltering( $par, $major, $minor ) { + public function testMimeFiltering( $par, $major, $minor ) { $this->page->run( $par ); $qi = $this->page->getQueryInfo(); $this->assertEquals( $qi['conds']['img_major_mime'], $major ); @@ -37,7 +37,7 @@ class SpecialMIMESearchTest extends MediaWikiTestCase { $this->assertContains( 'image', $qi['tables'] ); } - function providerMimeFiltering() { + public function providerMimeFiltering() { return [ [ 'image/gif', 'image', 'gif' ], [ 'image/png', 'image', 'png' ], diff --git a/tests/phpunit/includes/specials/SpecialSearchTest.php b/tests/phpunit/includes/specials/SpecialSearchTest.php index 1fd5af680fff..937913494195 100644 --- a/tests/phpunit/includes/specials/SpecialSearchTest.php +++ b/tests/phpunit/includes/specials/SpecialSearchTest.php @@ -121,7 +121,7 @@ class SpecialSearchTest extends MediaWikiTestCase { * User remains anonymous though * @param array|null $opt */ - function newUserWithSearchNS( $opt = null ) { + protected function newUserWithSearchNS( $opt = null ) { $u = User::newFromId( 0 ); if ( $opt === null ) { return $u; diff --git a/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php b/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php index 492b2509ce58..631e7d455466 100644 --- a/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php +++ b/tests/phpunit/includes/utils/ZipDirectoryReaderTest.php @@ -13,17 +13,17 @@ class ZipDirectoryReaderTest extends MediaWikiIntegrationTestCase { $this->zipDir = __DIR__ . '/../../data/zip'; } - function zipCallback( $entry ) { + public function zipCallback( $entry ) { $this->entries[] = $entry; } - function readZipAssertError( $file, $error, $assertMessage ) { + public function readZipAssertError( $file, $error, $assertMessage ) { $this->entries = []; $status = ZipDirectoryReader::read( "{$this->zipDir}/$file", [ $this, 'zipCallback' ] ); $this->assertTrue( $status->hasMessage( $error ), $assertMessage ); } - function readZipAssertSuccess( $file, $assertMessage ) { + public function readZipAssertSuccess( $file, $assertMessage ) { $this->entries = []; $status = ZipDirectoryReader::read( "{$this->zipDir}/$file", [ $this, 'zipCallback' ] ); $this->assertTrue( $status->isOK(), $assertMessage ); diff --git a/tests/phpunit/languages/LanguageConverterTest.php b/tests/phpunit/languages/LanguageConverterTest.php index 5dcb8e48085e..a271910b0007 100644 --- a/tests/phpunit/languages/LanguageConverterTest.php +++ b/tests/phpunit/languages/LanguageConverterTest.php @@ -323,7 +323,7 @@ class TestConverter extends LanguageConverter { 'г' => 'g', ]; - function loadDefaultTables() { + public function loadDefaultTables() { $this->mTables = [ 'sgs' => new ReplacementArray(), 'simple' => new ReplacementArray(), @@ -334,7 +334,7 @@ class TestConverter extends LanguageConverter { } class LanguageToTest extends Language { - function __construct() { + public function __construct() { parent::__construct(); $variants = [ 'tg', 'tg-latn' ]; $this->mConverter = new TestConverter( $this, 'tg', $variants ); diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index 958cdfe19020..be054e016fae 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -172,7 +172,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { /** * Checks for test output consisting only of lines containing ETA announcements */ - function expectETAOutput() { + protected function expectETAOutput() { // Newer PHPUnits require assertion about the output using PHPUnit's own // expectOutput[...] functions. However, the PHPUnit shipped prediactes // do not allow to check /each/ line of the output using /readable/ REs. diff --git a/tests/phpunit/maintenance/MaintenanceTest.php b/tests/phpunit/maintenance/MaintenanceTest.php index 141561f06708..3b8a933a64c5 100644 --- a/tests/phpunit/maintenance/MaintenanceTest.php +++ b/tests/phpunit/maintenance/MaintenanceTest.php @@ -40,7 +40,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { /** * @dataProvider provideOutputData */ - function testOutput( $outputs, $expected, $extraNL ) { + public function testOutput( $outputs, $expected, $extraNL ) { foreach ( $outputs as $data ) { if ( is_array( $data ) ) { list( $msg, $channel ) = $data; @@ -193,7 +193,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { /** * @dataProvider provideOutputChanneledData */ - function testOutputChanneled( $outputs, $expected, $extraNL ) { + public function testOutputChanneled( $outputs, $expected, $extraNL ) { foreach ( $outputs as $data ) { if ( is_array( $data ) ) { list( $msg, $channel ) = $data; @@ -305,66 +305,66 @@ class MaintenanceTest extends MaintenanceBaseTestCase { ]; } - function testCleanupChanneledClean() { + public function testCleanupChanneledClean() { $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "", false ); } - function testCleanupChanneledAfterOutput() { + public function testCleanupChanneledAfterOutput() { $this->maintenance->output( "foo" ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo", false ); } - function testCleanupChanneledAfterOutputWNullChannel() { + public function testCleanupChanneledAfterOutputWNullChannel() { $this->maintenance->output( "foo", null ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo", false ); } - function testCleanupChanneledAfterOutputWChannel() { + public function testCleanupChanneledAfterOutputWChannel() { $this->maintenance->output( "foo", "bazChannel" ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testCleanupChanneledAfterNLOutput() { + public function testCleanupChanneledAfterNLOutput() { $this->maintenance->output( "foo\n" ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testCleanupChanneledAfterNLOutputWNullChannel() { + public function testCleanupChanneledAfterNLOutputWNullChannel() { $this->maintenance->output( "foo\n", null ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testCleanupChanneledAfterNLOutputWChannel() { + public function testCleanupChanneledAfterNLOutputWChannel() { $this->maintenance->output( "foo\n", "bazChannel" ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testCleanupChanneledAfterOutputChanneledWOChannel() { + public function testCleanupChanneledAfterOutputChanneledWOChannel() { $this->maintenance->outputChanneled( "foo" ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testCleanupChanneledAfterOutputChanneledWNullChannel() { + public function testCleanupChanneledAfterOutputChanneledWNullChannel() { $this->maintenance->outputChanneled( "foo", null ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testCleanupChanneledAfterOutputChanneledWChannel() { + public function testCleanupChanneledAfterOutputChanneledWChannel() { $this->maintenance->outputChanneled( "foo", "bazChannel" ); $this->maintenance->cleanupChanneled(); $this->assertOutputPrePostShutdown( "foo\n", false ); } - function testMultipleMaintenanceObjectsInteractionOutput() { + public function testMultipleMaintenanceObjectsInteractionOutput() { $m2 = $this->createMaintenance(); $this->maintenance->output( "foo" ); @@ -376,7 +376,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foobar", false ); } - function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() { + public function testMultipleMaintenanceObjectsInteractionOutputWNullChannel() { $m2 = $this->createMaintenance(); $this->maintenance->output( "foo", null ); @@ -388,7 +388,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foobar", false ); } - function testMultipleMaintenanceObjectsInteractionOutputWChannel() { + public function testMultipleMaintenanceObjectsInteractionOutputWChannel() { $m2 = $this->createMaintenance(); $this->maintenance->output( "foo", "bazChannel" ); @@ -400,7 +400,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foobar\n", true ); } - function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() { + public function testMultipleMaintenanceObjectsInteractionOutputWNullChannelNL() { $m2 = $this->createMaintenance(); $this->maintenance->output( "foo\n", null ); @@ -412,7 +412,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foo\nbar\n", false ); } - function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() { + public function testMultipleMaintenanceObjectsInteractionOutputWChannelNL() { $m2 = $this->createMaintenance(); $this->maintenance->output( "foo\n", "bazChannel" ); @@ -424,7 +424,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foobar\n", true ); } - function testMultipleMaintenanceObjectsInteractionOutputChanneled() { + public function testMultipleMaintenanceObjectsInteractionOutputChanneled() { $m2 = $this->createMaintenance(); $this->maintenance->outputChanneled( "foo" ); @@ -436,7 +436,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foo\nbar\n", false ); } - function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() { + public function testMultipleMaintenanceObjectsInteractionOutputChanneledWNullChannel() { $m2 = $this->createMaintenance(); $this->maintenance->outputChanneled( "foo", null ); @@ -448,7 +448,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foo\nbar\n", false ); } - function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() { + public function testMultipleMaintenanceObjectsInteractionOutputChanneledWChannel() { $m2 = $this->createMaintenance(); $this->maintenance->outputChanneled( "foo", "bazChannel" ); @@ -460,7 +460,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertOutputPrePostShutdown( "foobar\n", true ); } - function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() { + public function testMultipleMaintenanceObjectsInteractionCleanupChanneledWChannel() { $m2 = $this->createMaintenance(); $this->maintenance->outputChanneled( "foo", "bazChannel" ); @@ -499,7 +499,7 @@ class MaintenanceTest extends MaintenanceBaseTestCase { $this->assertSame( $conf, $this->maintenance->getConfig() ); } - function testParseArgs() { + public function testParseArgs() { $m2 = $this->createMaintenance(); // Create an option with an argument allowed to be specified multiple times diff --git a/tests/phpunit/maintenance/backupPrefetchTest.php b/tests/phpunit/maintenance/backupPrefetchTest.php index 747d2bfa13f9..62e4c8a9ee45 100644 --- a/tests/phpunit/maintenance/backupPrefetchTest.php +++ b/tests/phpunit/maintenance/backupPrefetchTest.php @@ -40,7 +40,7 @@ class BaseDumpTest extends MediaWikiTestCase { "Prefetch of page $page revision $revision" ); } - function testSequential() { + public function testSequential() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -50,7 +50,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 ); } - function testSynchronizeRevisionMissToRevision() { + public function testSynchronizeRevisionMissToRevision() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -59,7 +59,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "BackupDumperTestP2Text4 some additional Text", 2, 5 ); } - function testSynchronizeRevisionMissToPage() { + public function testSynchronizeRevisionMissToPage() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -68,7 +68,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 ); } - function testSynchronizePageMiss() { + public function testSynchronizePageMiss() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -77,7 +77,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 ); } - function testPageMissAtEnd() { + public function testPageMissAtEnd() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -85,7 +85,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( null, 6, 40 ); } - function testRevisionMissAtEnd() { + public function testRevisionMissAtEnd() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -93,7 +93,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( null, 4, 40 ); } - function testSynchronizePageMissAtStart() { + public function testSynchronizePageMissAtStart() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -101,7 +101,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 ); } - function testSynchronizeRevisionMissAtStart() { + public function testSynchronizeRevisionMissAtStart() { $fname = $this->setUpPrefetch(); $this->dump = new BaseDump( $fname ); @@ -109,7 +109,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "BackupDumperTestP2Text1", 2, 2 ); } - function testSequentialAcrossFiles() { + public function testSequentialAcrossFiles() { $fname1 = $this->setUpPrefetch( [ 1 ] ); $fname2 = $this->setUpPrefetch( [ 2, 4 ] ); $this->dump = new BaseDump( $fname1 . ";" . $fname2 ); @@ -120,7 +120,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 ); } - function testSynchronizeSkipAcrossFile() { + public function testSynchronizeSkipAcrossFile() { $fname1 = $this->setUpPrefetch( [ 1 ] ); $fname2 = $this->setUpPrefetch( [ 2 ] ); $fname3 = $this->setUpPrefetch( [ 4 ] ); @@ -130,7 +130,7 @@ class BaseDumpTest extends MediaWikiTestCase { $this->assertPrefetchEquals( "Talk about BackupDumperTestP1 Text1", 4, 8 ); } - function testSynchronizeMissInWholeFirstFile() { + public function testSynchronizeMissInWholeFirstFile() { $fname1 = $this->setUpPrefetch( [ 1 ] ); $fname2 = $this->setUpPrefetch( [ 2 ] ); $this->dump = new BaseDump( $fname1 . ";" . $fname2 ); diff --git a/tests/phpunit/maintenance/backupTextPassTest.php b/tests/phpunit/maintenance/backupTextPassTest.php index e059834e2919..6b119b1709b9 100644 --- a/tests/phpunit/maintenance/backupTextPassTest.php +++ b/tests/phpunit/maintenance/backupTextPassTest.php @@ -36,7 +36,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { private $revId4_1, $textId4_1; private static $numOfRevs = 8; - function addDBData() { + public function addDBData() { $this->tablesUsed[] = 'page'; $this->tablesUsed[] = 'revision'; $this->tablesUsed[] = 'ip_changes'; @@ -117,7 +117,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { "Page ids increasing without holes" ); } - function testPlain() { + public function testPlain() { // Setting up the dump $nameStub = $this->setUpStub(); $nameFull = $this->getNewTempFile(); @@ -172,7 +172,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { $asserter->assertDumpEnd(); } - function testPrefetchPlain() { + public function testPrefetchPlain() { // The mapping between ids and text, for the hits of the prefetch mock $prefetchMap = [ [ $this->pageId1, $this->revId1_1, "Prefetch_________1Text1" ], @@ -484,7 +484,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { * @group large * @group Broken */ - function testCheckpointPlain() { + public function testCheckpointPlain() { $this->checkpointHelper(); } @@ -503,7 +503,7 @@ class TextPassDumperDatabaseTest extends DumpTestCase { * @group large * @group Broken */ - function testCheckpointGzip() { + public function testCheckpointGzip() { $this->checkHasGzip(); $this->checkpointHelper( "gzip" ); } @@ -702,7 +702,7 @@ class TextPassDumperDatabaselessTest extends MediaWikiLangTestCase { * * @dataProvider bufferSizeProvider */ - function testBufferSizeSetting( $expected, $size, $msg ) { + public function testBufferSizeSetting( $expected, $size, $msg ) { $dumper = new TextPassDumperAccessor(); $dumper->loadWithArgv( [ "--buffersize=" . $size ] ); $dumper->execute(); @@ -714,7 +714,7 @@ class TextPassDumperDatabaselessTest extends MediaWikiLangTestCase { * * @dataProvider bufferSizeProvider */ - function bufferSizeProvider() { + public function bufferSizeProvider() { // expected, bufferSize to initialize with, message return [ [ 512 * 1024, 512 * 1024, "Setting 512KB is not effective" ], @@ -746,7 +746,7 @@ class TextPassDumperAccessor extends TextPassDumper { return $this->bufferSize; } - function dump( $history, $text = null ) { + public function dump( $history, $text = null ) { return true; } } diff --git a/tests/phpunit/maintenance/backup_LogTest.php b/tests/phpunit/maintenance/backup_LogTest.php index 811f1ee501ca..4a4f41c0fe29 100644 --- a/tests/phpunit/maintenance/backup_LogTest.php +++ b/tests/phpunit/maintenance/backup_LogTest.php @@ -58,7 +58,7 @@ class BackupDumperLoggerTest extends DumpTestCase { return $logEntry->insert(); } - function addDBData() { + public function addDBData() { $this->tablesUsed[] = 'logging'; $this->tablesUsed[] = 'user'; @@ -99,7 +99,7 @@ class BackupDumperLoggerTest extends DumpTestCase { } } - function testPlain() { + public function testPlain() { // Preparing the dump $fname = $this->getNewTempFile(); @@ -137,7 +137,7 @@ class BackupDumperLoggerTest extends DumpTestCase { $asserter->assertDumpEnd(); } - function testXmlDumpsBackupUseCaseLogging() { + public function testXmlDumpsBackupUseCaseLogging() { $this->checkHasGzip(); // Preparing the dump diff --git a/tests/phpunit/maintenance/backup_PageTest.php b/tests/phpunit/maintenance/backup_PageTest.php index 54a362e7052e..3c00f147ec5d 100644 --- a/tests/phpunit/maintenance/backup_PageTest.php +++ b/tests/phpunit/maintenance/backup_PageTest.php @@ -44,7 +44,7 @@ class BackupDumperPageTest extends DumpTestCase { */ private $streamingLoadBalancer = null; - function addDBData() { + public function addDBData() { // be sure, titles created here using english namespace names $this->setContentLang( 'en' ); @@ -171,7 +171,7 @@ class BackupDumperPageTest extends DumpTestCase { "Page ids increasing without holes" ); } - function tearDown() { + public function tearDown() { parent::tearDown(); if ( isset( $this->streamingLoadBalancer ) ) { @@ -238,7 +238,7 @@ class BackupDumperPageTest extends DumpTestCase { /** * @dataProvider schemaVersionProvider */ - function testFullTextPlain( $schemaVersion ) { + public function testFullTextPlain( $schemaVersion ) { // Preparing the dump $fname = $this->getNewTempFile(); @@ -370,7 +370,7 @@ class BackupDumperPageTest extends DumpTestCase { /** * @dataProvider schemaVersionProvider */ - function testFullStubPlain( $schemaVersion ) { + public function testFullStubPlain( $schemaVersion ) { // Preparing the dump $fname = $this->getNewTempFile(); @@ -495,7 +495,7 @@ class BackupDumperPageTest extends DumpTestCase { /** * @dataProvider schemaVersionProvider */ - function testCurrentStubPlain( $schemaVersion ) { + public function testCurrentStubPlain( $schemaVersion ) { // Preparing the dump $fname = $this->getNewTempFile(); @@ -567,7 +567,7 @@ class BackupDumperPageTest extends DumpTestCase { $asserter->assertDumpEnd(); } - function testCurrentStubGzip() { + public function testCurrentStubGzip() { $this->checkHasGzip(); // Preparing the dump @@ -649,7 +649,7 @@ class BackupDumperPageTest extends DumpTestCase { * * @dataProvider schemaVersionProvider */ - function testXmlDumpsBackupUseCase( $schemaVersion ) { + public function testXmlDumpsBackupUseCase( $schemaVersion ) { $this->checkHasGzip(); $fnameMetaHistory = $this->getNewTempFile(); diff --git a/tests/phpunit/maintenance/fetchTextTest.php b/tests/phpunit/maintenance/fetchTextTest.php index 038827e81305..6e3899e4a4b8 100644 --- a/tests/phpunit/maintenance/fetchTextTest.php +++ b/tests/phpunit/maintenance/fetchTextTest.php @@ -39,7 +39,7 @@ class SemiMockedFetchText extends FetchText { * * @param string $stdin The string to be used instead of stdin */ - function mockStdin( $stdin ) { + public function mockStdin( $stdin ) { $this->mockStdinText = $stdin; $this->mockSetUp = true; } @@ -50,14 +50,14 @@ class SemiMockedFetchText extends FetchText { * @return array An array, whose keys are function names. The corresponding values * denote the number of times the function has been invoked. */ - function mockGetInvocations() { + public function mockGetInvocations() { return $this->mockInvocations; } // ----------------------------------------------------------------- // Mocked functions from FetchText follow. - function getStdin( $len = null ) { + public function getStdin( $len = null ) { $this->mockInvocations['getStdin']++; if ( $len !== null ) { throw new ExpectationFailedException( @@ -131,7 +131,7 @@ class FetchTextTest extends MediaWikiTestCase { throw new MWException( "Could not create revision" ); } - function addDBDataOnce() { + public function addDBDataOnce() { $wikitextNamespace = $this->getDefaultWikitextNS(); try { @@ -201,22 +201,22 @@ class FetchTextTest extends MediaWikiTestCase { // However, as data providers are evaluated /before/ addDBData, a data // provider would not know the required ids. - function testExistingSimple() { + public function testExistingSimple() { $this->assertFilter( self::$textId2, self::$textId2 . "\n23\nFetchTextTestPage2Text1" ); } - function testExistingSimpleWithNewline() { + public function testExistingSimpleWithNewline() { $this->assertFilter( self::$textId2 . "\n", self::$textId2 . "\n23\nFetchTextTestPage2Text1" ); } - function testExistingInteger() { + public function testExistingInteger() { $this->assertFilter( (int)preg_replace( '/^tt:/', '', self::$textId2 ), self::$textId2 . "\n23\nFetchTextTestPage2Text1" ); } - function testExistingSeveral() { + public function testExistingSeveral() { $this->assertFilter( implode( "\n", [ self::$textId1, @@ -233,49 +233,49 @@ class FetchTextTest extends MediaWikiTestCase { ] ) ); } - function testEmpty() { + public function testEmpty() { $this->assertFilter( "", null ); } - function testNonExisting() { + public function testNonExisting() { \Wikimedia\suppressWarnings(); $this->assertFilter( 'tt:77889911', 'tt:77889911' . "\n-1\n" ); \Wikimedia\suppressWarnings( true ); } - function testNonExistingInteger() { + public function testNonExistingInteger() { \Wikimedia\suppressWarnings(); $this->assertFilter( '77889911', 'tt:77889911' . "\n-1\n" ); \Wikimedia\suppressWarnings( true ); } - function testBadBlobAddressWithColon() { + public function testBadBlobAddressWithColon() { $this->assertFilter( 'foo:bar', 'foo:bar' . "\n-1\n" ); } - function testNegativeInteger() { + public function testNegativeInteger() { $this->assertFilter( "-42", "tt:-42\n-1\n" ); } - function testFloatingPointNumberExisting() { + public function testFloatingPointNumberExisting() { // float -> int -> address -> revision $id = intval( preg_replace( '/^tt:/', '', self::$textId3 ) ) + 0.14159; $this->assertFilter( 'tt:' . intval( $id ), self::$textId3 . "\n23\nFetchTextTestPage2Text2" ); } - function testFloatingPointNumberNonExisting() { + public function testFloatingPointNumberNonExisting() { \Wikimedia\suppressWarnings(); $id = intval( preg_replace( '/^tt:/', '', self::$textId5 ) ) + 3.14159; $this->assertFilter( $id, 'tt:' . intval( $id ) . "\n-1\n" ); \Wikimedia\suppressWarnings( true ); } - function testCharacters() { + public function testCharacters() { $this->assertFilter( "abc", "abc\n-1\n" ); } - function testMix() { + public function testMix() { $this->assertFilter( "ab\n" . self::$textId4 . ".5cd\n\nefg\nfoo:bar\n" . self::$textId2 . "\n" . self::$textId3, implode( "", [ diff --git a/tests/phpunit/mocks/media/MockBitmapHandler.php b/tests/phpunit/mocks/media/MockBitmapHandler.php index 38cacf9f2e8f..e40c30ebfab7 100644 --- a/tests/phpunit/mocks/media/MockBitmapHandler.php +++ b/tests/phpunit/mocks/media/MockBitmapHandler.php @@ -22,11 +22,11 @@ */ class MockBitmapHandler extends BitmapHandler { - function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { + public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { return MockImageHandler::doFakeTransform( $this, $image, $dstPath, $dstUrl, $params, $flags ); } - function doClientImage( $image, $scalerParams ) { + public function doClientImage( $image, $scalerParams ) { return $this->getClientScalingThumbnailImage( $image, $scalerParams ); } } diff --git a/tests/phpunit/mocks/media/MockDjVuHandler.php b/tests/phpunit/mocks/media/MockDjVuHandler.php index 29cc6b3c074f..a8ba34db73cd 100644 --- a/tests/phpunit/mocks/media/MockDjVuHandler.php +++ b/tests/phpunit/mocks/media/MockDjVuHandler.php @@ -26,7 +26,7 @@ class MockDjVuHandler extends DjVuHandler { return true; } - function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { + public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { if ( !$this->normaliseParams( $image, $params ) ) { return new TransformParameterError( $params ); } diff --git a/tests/phpunit/mocks/media/MockImageHandler.php b/tests/phpunit/mocks/media/MockImageHandler.php index e0082919f017..15406eab54e4 100644 --- a/tests/phpunit/mocks/media/MockImageHandler.php +++ b/tests/phpunit/mocks/media/MockImageHandler.php @@ -43,7 +43,7 @@ class MockImageHandler { * @param int $flags * @return ThumbnailImage */ - static function doFakeTransform( $that, $image, $dstPath, $dstUrl, $params, $flags = 0 ) { + public static function doFakeTransform( $that, $image, $dstPath, $dstUrl, $params, $flags = 0 ) { # Example of what we receive: # $image: LocalFile # $dstPath: /tmp/transform_7d0a7a2f1a09-1.jpg diff --git a/tests/phpunit/mocks/media/MockSvgHandler.php b/tests/phpunit/mocks/media/MockSvgHandler.php index 21520c44553c..907543deb86d 100644 --- a/tests/phpunit/mocks/media/MockSvgHandler.php +++ b/tests/phpunit/mocks/media/MockSvgHandler.php @@ -22,7 +22,7 @@ */ class MockSvgHandler extends SvgHandler { - function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { + public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { return MockImageHandler::doFakeTransform( $this, $image, $dstPath, $dstUrl, $params, $flags ); } } diff --git a/tests/phpunit/suites/ParserTestFileSuite.php b/tests/phpunit/suites/ParserTestFileSuite.php index 22ea5543c38c..843718d046cc 100644 --- a/tests/phpunit/suites/ParserTestFileSuite.php +++ b/tests/phpunit/suites/ParserTestFileSuite.php @@ -12,7 +12,7 @@ class ParserTestFileSuite extends TestSuite { private $ptFileName; private $ptFileInfo; - function __construct( $runner, $name, $fileName ) { + public function __construct( $runner, $name, $fileName ) { parent::__construct( $name ); $this->ptRunner = $runner; $this->ptFileName = $fileName; @@ -24,7 +24,7 @@ class ParserTestFileSuite extends TestSuite { } } - function setUp() { + public function setUp() { if ( !$this->ptRunner->meetsRequirements( $this->ptFileInfo['requirements'] ) ) { $this->markTestSuiteSkipped( 'required extension not enabled' ); } else { diff --git a/tests/phpunit/suites/ParserTestTopLevelSuite.php b/tests/phpunit/suites/ParserTestTopLevelSuite.php index 797fa430deb3..bec809fb6ef6 100644 --- a/tests/phpunit/suites/ParserTestTopLevelSuite.php +++ b/tests/phpunit/suites/ParserTestTopLevelSuite.php @@ -65,7 +65,7 @@ class ParserTestTopLevelSuite extends TestSuite { return new self( $flags ); } - function __construct( $flags ) { + public function __construct( $flags ) { parent::__construct(); $this->ptRecorder = new PhpunitTestRecorder; diff --git a/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php b/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php index ae397d532b08..8a00da124967 100644 --- a/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php +++ b/tests/phpunit/unit/includes/GlobalFunctions/wfGetCallerTest.php @@ -9,7 +9,7 @@ class WfGetCallerTest extends MediaWikiUnitTestCase { $this->assertEquals( 'WfGetCallerTest->testZero', wfGetCaller( 1 ) ); } - function callerOne() { + public function callerOne() { return wfGetCaller(); } @@ -17,7 +17,7 @@ class WfGetCallerTest extends MediaWikiUnitTestCase { $this->assertEquals( 'WfGetCallerTest->testOne', self::callerOne() ); } - static function intermediateFunction( $level = 2, $n = 0 ) { + public static function intermediateFunction( $level = 2, $n = 0 ) { if ( $n > 0 ) { return self::intermediateFunction( $level, $n - 1 ); } diff --git a/tests/phpunit/unit/includes/Rest/ResponseFactoryTest.php b/tests/phpunit/unit/includes/Rest/ResponseFactoryTest.php index 3f3123b1f68e..fae01dfc5984 100644 --- a/tests/phpunit/unit/includes/Rest/ResponseFactoryTest.php +++ b/tests/phpunit/unit/includes/Rest/ResponseFactoryTest.php @@ -23,11 +23,11 @@ class ResponseFactoryTest extends MediaWikiUnitTestCase { private function createResponseFactory() { $fakeTextFormatter = new class implements ITextFormatter { - function getLangCode() { + public function getLangCode() { return 'qqx'; } - function format( MessageValue $message ) { + public function format( MessageValue $message ) { return $message->getKey(); } }; diff --git a/tests/phpunit/unit/includes/Storage/PreparedEditTest.php b/tests/phpunit/unit/includes/Storage/PreparedEditTest.php index e3249e74bc2c..b32d6b395b2c 100644 --- a/tests/phpunit/unit/includes/Storage/PreparedEditTest.php +++ b/tests/phpunit/unit/includes/Storage/PreparedEditTest.php @@ -8,7 +8,7 @@ use ParserOutput; * @covers \MediaWiki\Edit\PreparedEdit */ class PreparedEditTest extends \MediaWikiUnitTestCase { - function testCallback() { + public function testCallback() { $output = new ParserOutput(); $edit = new PreparedEdit(); $edit->parserOutputCallback = function () { |