From 69ec133bc5f2e80265e71fce094e046699d50487 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 24 Apr 2014 19:52:34 +0200 Subject: [PATCH] Pass phpcs-strict on some test files (10/11) Change-Id: I5624292143fcabe890779f5095eae735d7afb176 --- tests/phpunit/includes/parser/TagHooksTest.php | 32 ++++++++++++++++++---- .../includes/resourceloader/ResourceLoaderTest.php | 3 +- tests/phpunit/includes/search/SearchEngineTest.php | 6 +++- tests/phpunit/includes/site/MediaWikiSiteTest.php | 21 ++++++++++++-- .../includes/specials/QueryAllSpecialPagesTest.php | 4 +-- .../includes/specials/SpecialSearchTest.php | 11 ++++---- .../includes/title/MediaWikiTitleCodecTest.php | 15 ++++++++-- .../phpunit/includes/upload/UploadFromUrlTest.php | 14 ++++++++-- tests/phpunit/languages/LanguageBe_taraskTest.php | 2 ++ tests/phpunit/languages/LanguageTest.php | 28 ++++++++++++++----- 10 files changed, 107 insertions(+), 29 deletions(-) diff --git a/tests/phpunit/includes/parser/TagHooksTest.php b/tests/phpunit/includes/parser/TagHooksTest.php index 259a9e2a360..e3c4cc84634 100644 --- a/tests/phpunit/includes/parser/TagHooksTest.php +++ b/tests/phpunit/includes/parser/TagHooksTest.php @@ -5,7 +5,13 @@ */ class TagHookTest extends MediaWikiTestCase { public static function provideValidNames() { - return array( array( 'foo' ), array( 'foo-bar' ), array( 'foo_bar' ), array( 'FOO-BAR' ), array( 'foo bar' ) ); + return array( + array( 'foo' ), + array( 'foo-bar' ), + array( 'foo_bar' ), + array( 'FOO-BAR' ), + array( 'foo bar' ) + ); } public static function provideBadNames() { @@ -27,7 +33,11 @@ class TagHookTest extends MediaWikiTestCase { $parser = new Parser( $wgParserConf ); $parser->setHook( $tag, array( $this, 'tagCallback' ) ); - $parserOutput = $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) ); + $parserOutput = $parser->parse( + "Foo<$tag>BarBaz", + Title::newFromText( 'Test' ), + ParserOptions::newFromUserAndLang( new User, $wgContLang ) + ); $this->assertEquals( "

FooOneBaz\n

", $parserOutput->getText() ); $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle @@ -43,7 +53,11 @@ class TagHookTest extends MediaWikiTestCase { $parser = new Parser( $wgParserConf ); $parser->setHook( $tag, array( $this, 'tagCallback' ) ); - $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) ); + $parser->parse( + "Foo<$tag>BarBaz", + Title::newFromText( 'Test' ), + ParserOptions::newFromUserAndLang( new User, $wgContLang ) + ); $this->fail( 'Exception not thrown.' ); } @@ -56,7 +70,11 @@ class TagHookTest extends MediaWikiTestCase { $parser = new Parser( $wgParserConf ); $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), 0 ); - $parserOutput = $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) ); + $parserOutput = $parser->parse( + "Foo<$tag>BarBaz", + Title::newFromText( 'Test' ), + ParserOptions::newFromUserAndLang( new User, $wgContLang ) + ); $this->assertEquals( "

FooOneBaz\n

", $parserOutput->getText() ); $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle @@ -72,7 +90,11 @@ class TagHookTest extends MediaWikiTestCase { $parser = new Parser( $wgParserConf ); $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), SFH_OBJECT_ARGS ); - $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) ); + $parser->parse( + "Foo<$tag>BarBaz", + Title::newFromText( 'Test' ), + ParserOptions::newFromUserAndLang( new User, $wgContLang ) + ); $this->fail( 'Exception not thrown.' ); } diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index ab0c8d9b140..d3736f50a92 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -51,7 +51,8 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { /* Test Methods */ /** - * Ensures that the ResourceLoaderRegisterModules hook is called when a new ResourceLoader object is constructed + * Ensures that the ResourceLoaderRegisterModules hook is called when a new + * ResourceLoader object is constructed. * @covers ResourceLoader::__construct */ public function testCreatingNewResourceLoaderCallsRegistrationHook() { diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php index b0c0f1b5f56..3da1361530f 100644 --- a/tests/phpunit/includes/search/SearchEngineTest.php +++ b/tests/phpunit/includes/search/SearchEngineTest.php @@ -57,7 +57,11 @@ class SearchEngineTest extends MediaWikiLangTestCase { } $this->insertPage( "Not_Main_Page", "This is not a main page", 0 ); - $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 ); + $this->insertPage( + 'Talk:Not_Main_Page', + 'This is not a talk page to the main page, see [[smithee]]', + 1 + ); $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 ); $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 ); $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 ); diff --git a/tests/phpunit/includes/site/MediaWikiSiteTest.php b/tests/phpunit/includes/site/MediaWikiSiteTest.php index c5d52d338e8..15b88658d7b 100644 --- a/tests/phpunit/includes/site/MediaWikiSiteTest.php +++ b/tests/phpunit/includes/site/MediaWikiSiteTest.php @@ -46,9 +46,24 @@ class MediaWikiSiteTest extends SiteTest { // url, filepath, path arg, expected array( 'https://en.wikipedia.org', '/w/$1', 'api.php', 'https://en.wikipedia.org/w/api.php' ), array( 'https://en.wikipedia.org', '/w/', 'api.php', 'https://en.wikipedia.org/w/' ), - array( 'https://en.wikipedia.org', '/foo/page.php?name=$1', 'api.php', 'https://en.wikipedia.org/foo/page.php?name=api.php' ), - array( 'https://en.wikipedia.org', '/w/$1', '', 'https://en.wikipedia.org/w/' ), - array( 'https://en.wikipedia.org', '/w/$1', 'foo/bar/api.php', 'https://en.wikipedia.org/w/foo/bar/api.php' ), + array( + 'https://en.wikipedia.org', + '/foo/page.php?name=$1', + 'api.php', + 'https://en.wikipedia.org/foo/page.php?name=api.php' + ), + array( + 'https://en.wikipedia.org', + '/w/$1', + '', + 'https://en.wikipedia.org/w/' + ), + array( + 'https://en.wikipedia.org', + '/w/$1', + 'foo/bar/api.php', + 'https://en.wikipedia.org/w/foo/bar/api.php' + ), ); } diff --git a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php index 39462b4a5ef..f92dc66fc03 100644 --- a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php +++ b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php @@ -50,14 +50,14 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase { global $wgDBtype; foreach ( $this->queryPages as $page ) { - // With MySQL, skips special pages reopening a temporary table // See http://bugs.mysql.com/bug.php?id=10327 if ( $wgDBtype === 'mysql' && in_array( $page->getName(), $this->reopensTempTable ) ) { - $this->markTestSkipped( "SQL query for page {$page->getName()} can not be tested on MySQL backend (it reopens a temporary table)" ); + $this->markTestSkipped( "SQL query for page {$page->getName()} " + . "can not be tested on MySQL backend (it reopens a temporary table)" ); continue; } diff --git a/tests/phpunit/includes/specials/SpecialSearchTest.php b/tests/phpunit/includes/specials/SpecialSearchTest.php index 8cbcf972da6..dbebeb7a3db 100644 --- a/tests/phpunit/includes/specials/SpecialSearchTest.php +++ b/tests/phpunit/includes/specials/SpecialSearchTest.php @@ -13,14 +13,15 @@ class SpecialSearchTest extends MediaWikiTestCase { /** * @covers SpecialSearch::load * @dataProvider provideSearchOptionsTests - * @param array $requested Request parameters. For example array( 'ns5' => true, 'ns6' => true). Null to use default options. - * @param array $userOptions User options to test with. For example array('searchNs5' => 1 );. Null to use default options. + * @param array $requested Request parameters. For example: + * array( 'ns5' => true, 'ns6' => true). Null to use default options. + * @param array $userOptions User options to test with. For example: + * array('searchNs5' => 1 );. Null to use default options. * @param string $expectedProfile An expected search profile name * @param array $expectedNs Expected namespaces */ - public function testProfileAndNamespaceLoading( - $requested, $userOptions, $expectedProfile, $expectedNS, - $message = 'Profile name and namespaces mismatches!' + public function testProfileAndNamespaceLoading( $requested, $userOptions, + $expectedProfile, $expectedNS, $message = 'Profile name and namespaces mismatches!' ) { $context = new RequestContext; $context->setUser( diff --git a/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php b/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php index ac3e41e28b6..1e5aca91294 100644 --- a/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php +++ b/tests/phpunit/includes/title/MediaWikiTitleCodecTest.php @@ -89,7 +89,14 @@ class MediaWikiTitleCodecTest extends MediaWikiTestCase { array( NS_MAIN, 'Foo_Bar', '', 'en', 'Foo Bar' ), array( NS_USER, 'Hansi_Maier', 'stuff_and_so_on', 'en', 'User:Hansi Maier#stuff and so on' ), array( false, 'Hansi_Maier', '', 'en', 'Hansi Maier' ), - array( NS_USER_TALK, 'hansi__maier', '', 'en', 'User talk:hansi maier', 'User talk:Hansi maier' ), + array( + NS_USER_TALK, + 'hansi__maier', + '', + 'en', + 'User talk:hansi maier', + 'User talk:Hansi maier' + ), // getGenderCache() provides a mock that considers first // names ending in "a" to be female. @@ -112,7 +119,11 @@ class MediaWikiTitleCodecTest extends MediaWikiTestCase { // test round trip $parsed = $codec->parseTitle( $actual, NS_MAIN ); - $actual2 = $codec->formatTitle( $parsed->getNamespace(), $parsed->getText(), $parsed->getFragment() ); + $actual2 = $codec->formatTitle( + $parsed->getNamespace(), + $parsed->getText(), + $parsed->getFragment() + ); $this->assertEquals( $normalized, $actual2, 'normalized after round trip' ); } diff --git a/tests/phpunit/includes/upload/UploadFromUrlTest.php b/tests/phpunit/includes/upload/UploadFromUrlTest.php index 879d82185ae..7125247e8f0 100644 --- a/tests/phpunit/includes/upload/UploadFromUrlTest.php +++ b/tests/phpunit/includes/upload/UploadFromUrlTest.php @@ -23,7 +23,9 @@ class UploadFromUrlTest extends ApiTestCase { } } - protected function doApiRequest( array $params, array $unused = null, $appendModule = false, User $user = null ) { + protected function doApiRequest( array $params, array $unused = null, + $appendModule = false, User $user = null + ) { $sessionId = session_id(); session_write_close(); @@ -203,7 +205,10 @@ class UploadFromUrlTest extends ApiTestCase { $page->doDeleteArticle( '' ); } - $this->assertFalse( (bool)$talk->getArticleID( Title::GAID_FOR_UPDATE ), 'User talk does not exist' ); + $this->assertFalse( + (bool)$talk->getArticleID( Title::GAID_FOR_UPDATE ), + 'User talk does not exist' + ); $this->doApiRequest( array( 'action' => 'upload', @@ -236,7 +241,10 @@ class UploadFromUrlTest extends ApiTestCase { ) ); } catch ( UsageException $e ) { $exception = true; - $this->assertEquals( 'Using leavemessage without ignorewarnings is not supported', $e->getMessage() ); + $this->assertEquals( + 'Using leavemessage without ignorewarnings is not supported', + $e->getMessage() + ); } $this->assertTrue( $exception ); diff --git a/tests/phpunit/languages/LanguageBe_taraskTest.php b/tests/phpunit/languages/LanguageBe_taraskTest.php index dbdb5889918..4dd5cdd7a34 100644 --- a/tests/phpunit/languages/LanguageBe_taraskTest.php +++ b/tests/phpunit/languages/LanguageBe_taraskTest.php @@ -1,6 +1,8 @@ markTestSkipped( 'The LanguageNames class is not available. The cldr extension is probably not installed.' ); + $this->markTestSkipped( 'The LanguageNames class is not available. ' + . 'The CLDR extension is probably not installed.' ); } $this->assertTrue( (bool)Language::isKnownLanguageTag( 'pal' ), - 'validating code "pal" an ancient language, which probably will not appear in Names.php, but appears in CLDR in English' + 'validating code "pal" an ancient language, which probably will ' + . 'not appear in Names.php, but appears in CLDR in English' ); } @@ -658,7 +663,8 @@ class LanguageTest extends LanguageClassesTestCase { '2009-W53-4', 'leap week' ), - // What follows is mostly copied from https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23time + // What follows is mostly copied from + // https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23time array( 'Y', '20120102090705', @@ -1284,6 +1290,7 @@ class LanguageTest extends LanguageClassesTestCase { } public static function provideCheckTitleEncodingData() { + // @codingStandardsIgnoreStart Ignore Generic.Files.LineLength.TooLong return array( array( "" ), array( "United States of America" ), // 7bit ASCII @@ -1334,6 +1341,7 @@ class LanguageTest extends LanguageClassesTestCase { ) ) ); + // @codingStandardsIgnoreEnd } /** @@ -1464,7 +1472,11 @@ class LanguageTest extends LanguageClassesTestCase { array( array( 'formatDuration', 1023 * 60 * 60 ), '1023 hours', 'relative' ), array( array( 'formatDuration', -1023 ), '-1023 seconds', 'negative relative' ), array( array( 'formatDuration', 0 ), 'now', 'now' ), - array( array( 'timeanddate', '20120102070000' ), '2012-1-1 7:00 +1 day', 'mixed, handled as absolute' ), + array( + array( 'timeanddate', '20120102070000' ), + '2012-1-1 7:00 +1 day', + 'mixed, handled as absolute' + ), array( array( 'timeanddate', '19910203040506' ), '1991-2-3 4:05:06', 'absolute' ), array( array( 'timeanddate', '19700101000000' ), '1970-1-1 0:00:00', 'absolute at epoch' ), array( array( 'timeanddate', '19691231235959' ), '1969-12-31 23:59:59', 'time before epoch' ), @@ -1555,10 +1567,12 @@ class LanguageTest extends LanguageClassesTestCase { public static function provideGetParentLanguage() { return array( array( 'zh-cn', 'zh', 'zh is the parent language of zh-cn' ), - array( 'zh', 'zh', 'zh is defined as the parent language of zh, because zh converter can convert zh-cn to zh' ), + array( 'zh', 'zh', 'zh is defined as the parent language of zh, ' + . 'because zh converter can convert zh-cn to zh' ), array( 'zh-invalid', null, 'do not be fooled by arbitrarily composed language codes' ), array( 'en-gb', null, 'en does not have converter' ), - array( 'en', null, 'en does not have converter. Although FakeConverter handles en -> en conversion but it is useless' ), + array( 'en', null, 'en does not have converter. Although FakeConverter ' + . 'handles en -> en conversion but it is useless' ), ); } -- 2.11.4.GIT