Pass phpcs-strict on some test files (10/11)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 17:52:34 +0000 (19:52 +0200)
committerChad Horohoe <chadh@wikimedia.org>
Thu, 24 Apr 2014 20:50:56 +0000 (13:50 -0700)
Change-Id: I5624292143fcabe890779f5095eae735d7afb176

tests/phpunit/includes/parser/TagHooksTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
tests/phpunit/includes/search/SearchEngineTest.php
tests/phpunit/includes/site/MediaWikiSiteTest.php
tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
tests/phpunit/includes/specials/SpecialSearchTest.php
tests/phpunit/includes/title/MediaWikiTitleCodecTest.php
tests/phpunit/includes/upload/UploadFromUrlTest.php
tests/phpunit/languages/LanguageBe_taraskTest.php
tests/phpunit/languages/LanguageTest.php

index 259a9e2..e3c4cc8 100644 (file)
@@ -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>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
+               $parserOutput = $parser->parse(
+                       "Foo<$tag>Bar</$tag>Baz",
+                       Title::newFromText( 'Test' ),
+                       ParserOptions::newFromUserAndLang( new User, $wgContLang )
+               );
                $this->assertEquals( "<p>FooOneBaz\n</p>", $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>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
+               $parser->parse(
+                       "Foo<$tag>Bar</$tag>Baz",
+                       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>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
+               $parserOutput = $parser->parse(
+                       "Foo<$tag>Bar</$tag>Baz",
+                       Title::newFromText( 'Test' ),
+                       ParserOptions::newFromUserAndLang( new User, $wgContLang )
+               );
                $this->assertEquals( "<p>FooOneBaz\n</p>", $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>Bar</$tag>Baz", Title::newFromText( 'Test' ), ParserOptions::newFromUserAndLang( new User, $wgContLang ) );
+               $parser->parse(
+                       "Foo<$tag>Bar</$tag>Baz",
+                       Title::newFromText( 'Test' ),
+                       ParserOptions::newFromUserAndLang( new User, $wgContLang )
+               );
                $this->fail( 'Exception not thrown.' );
        }
 
index ab0c8d9..d3736f5 100644 (file)
@@ -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() {
index b0c0f1b..3da1361 100644 (file)
@@ -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 );
index c5d52d3..15b8865 100644 (file)
@@ -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'
+                       ),
                );
        }
 
index 39462b4..f92dc66 100644 (file)
@@ -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;
                        }
 
index 8cbcf97..dbebeb7 100644 (file)
@@ -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(
index ac3e41e..1e5aca9 100644 (file)
@@ -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' );
        }
index 879d821..7125247 100644 (file)
@@ -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 );
 
index dbdb588..4dd5cdd 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 
+// @codingStandardsIgnoreStart Ignore Squiz.Classes.ValidClassName.NotCamelCaps
 class LanguageBe_taraskTest extends LanguageClassesTestCase {
+       // @codingStandardsIgnoreEnd
        /**
         * Make sure the language code we are given is indeed
         * be-tarask. This is to ensure LanguageClassesTestCase
index 13d84f7..5e6cba0 100644 (file)
@@ -412,7 +412,10 @@ class LanguageTest extends LanguageClassesTestCase {
                        array( 'fr-Latn-F', 'region too short' ),
                        array( 'a-value', 'language too short with region' ),
                        array( 'tlh-a-b-foo', 'valid three-letter with wrong variant' ),
-                       array( 'i-notexist', 'grandfathered but not registered: invalid, even if we only test well-formedness' ),
+                       array(
+                               'i-notexist',
+                               'grandfathered but not registered: invalid, even if we only test well-formedness'
+                       ),
                        array( 'abcdefghi-012345678', 'numbers too long' ),
                        array( 'ab-abc-abc-abc-abc', 'invalid extensions' ),
                        array( 'ab-abcd-abc', 'invalid extensions' ),
@@ -508,12 +511,14 @@ class LanguageTest extends LanguageClassesTestCase {
         */
        public function testKnownCldrLanguageTag() {
                if ( !class_exists( 'LanguageNames' ) ) {
-                       $this->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' ),
                );
        }