Pass phpcs-strict on some test files (2/x)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 10:05:52 +0000 (12:05 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 15:05:34 +0000 (17:05 +0200)
Change-Id: Ia39fd107a554206927652b6e168faa0da501b362

tests/phpunit/includes/FallbackTest.php
tests/phpunit/includes/FauxRequestTest.php
tests/phpunit/includes/FauxResponseTest.php
tests/phpunit/includes/HooksTest.php
tests/phpunit/includes/HtmlFormatterTest.php
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/HttpTest.php
tests/phpunit/includes/LinkerTest.php
tests/phpunit/includes/LinksUpdateTest.php
tests/phpunit/includes/MWNamespaceTest.php

index 910b766..c60170f 100644 (file)
@@ -4,11 +4,11 @@
  * @covers Fallback
  */
 class FallbackTest extends MediaWikiTestCase {
-
        public function testFallbackMbstringFunctions() {
-
                if ( !extension_loaded( 'mbstring' ) ) {
-                       $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" );
+                       $this->markTestSkipped(
+                               "The mb_string functions must be installed to test the fallback functions"
+                       );
                }
 
                $sampleUTF = "Östergötland_coat_of_arms.png";
index 3246410..745a5b4 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
 class FauxRequestTest extends MediaWikiTestCase {
-
        /**
         * @covers FauxRequest::setHeader
         * @covers FauxRequest::getHeader
index 7f41cfd..4a974ba 100644 (file)
@@ -49,16 +49,32 @@ class FauxResponseTest extends MediaWikiTestCase {
                $this->assertEquals( null, $this->response->getheader( 'Location' ), 'Non-existing header' );
 
                $this->response->header( 'Location: http://localhost/' );
-               $this->assertEquals( 'http://localhost/', $this->response->getheader( 'Location' ), 'Set header' );
+               $this->assertEquals(
+                       'http://localhost/',
+                       $this->response->getheader( 'Location' ),
+                       'Set header'
+               );
 
                $this->response->header( 'Location: http://127.0.0.1/' );
-               $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header' );
+               $this->assertEquals(
+                       'http://127.0.0.1/',
+                       $this->response->getheader( 'Location' ),
+                       'Same header'
+               );
 
                $this->response->header( 'Location: http://127.0.0.2/', false );
-               $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header with override disabled' );
+               $this->assertEquals(
+                       'http://127.0.0.1/',
+                       $this->response->getheader( 'Location' ),
+                       'Same header with override disabled'
+               );
 
                $this->response->header( 'Location: http://localhost/' );
-               $this->assertEquals( 'http://localhost/', $this->response->getheader( 'LOCATION' ), 'Get header case insensitive' );
+               $this->assertEquals(
+                       'http://localhost/',
+                       $this->response->getheader( 'LOCATION' ),
+                       'Get header case insensitive'
+               );
        }
 
        /**
@@ -69,18 +85,34 @@ class FauxResponseTest extends MediaWikiTestCase {
                $this->assertEquals( 200, $this->response->getStatusCode(), 'Header with no message' );
 
                $this->response->header( 'HTTP/1.x 201' );
-               $this->assertEquals( 201, $this->response->getStatusCode(), 'Header with no message and protocol 1.x' );
+               $this->assertEquals(
+                       201,
+                       $this->response->getStatusCode(),
+                       'Header with no message and protocol 1.x'
+               );
 
                $this->response->header( 'HTTP/1.1 202 OK' );
                $this->assertEquals( 202, $this->response->getStatusCode(), 'Normal header' );
 
                $this->response->header( 'HTTP/1.x 203 OK' );
-               $this->assertEquals( 203, $this->response->getStatusCode(), 'Normal header with no message and protocol 1.x' );
+               $this->assertEquals(
+                       203,
+                       $this->response->getStatusCode(),
+                       'Normal header with no message and protocol 1.x'
+               );
 
                $this->response->header( 'HTTP/1.x 204 OK', false, 205 );
-               $this->assertEquals( 205, $this->response->getStatusCode(), 'Third parameter overrides the HTTP/... header' );
+               $this->assertEquals(
+                       205,
+                       $this->response->getStatusCode(),
+                       'Third parameter overrides the HTTP/... header'
+               );
 
                $this->response->header( 'Location: http://localhost/', false, 206 );
-               $this->assertEquals( 206, $this->response->getStatusCode(), 'Third parameter with another header' );
+               $this->assertEquals(
+                       206,
+                       $this->response->getStatusCode(),
+                       'Third parameter with another header'
+               );
        }
 }
index 87af6c1..74d4b09 100644 (file)
@@ -13,11 +13,26 @@ class HooksTest extends MediaWikiTestCase {
                $i = new NothingClass();
 
                return array(
-                       array( 'Object and method', array( $i, 'someNonStatic' ), 'changed-nonstatic', 'changed-nonstatic' ),
+                       array(
+                               'Object and method',
+                               array( $i, 'someNonStatic' ),
+                               'changed-nonstatic',
+                               'changed-nonstatic'
+                       ),
                        array( 'Object and no method', array( $i ), 'changed-onevent', 'original' ),
-                       array( 'Object and method with data', array( $i, 'someNonStaticWithData', 'data' ), 'data', 'original' ),
+                       array(
+                               'Object and method with data',
+                               array( $i, 'someNonStaticWithData', 'data' ),
+                               'data',
+                               'original'
+                       ),
                        array( 'Object and static method', array( $i, 'someStatic' ), 'changed-static', 'original' ),
-                       array( 'Class::method static call', array( 'NothingClass::someStatic' ), 'changed-static', 'original' ),
+                       array(
+                               'Class::method static call',
+                               array( 'NothingClass::someStatic' ),
+                               'changed-static',
+                               'original'
+                       ),
                        array( 'Global function', array( 'NothingFunction' ), 'changed-func', 'original' ),
                        array( 'Global function with data', array( 'NothingFunctionData', 'data' ), 'data', 'original' ),
                        array( 'Closure', array( function ( &$foo, $bar ) {
@@ -76,17 +91,32 @@ class HooksTest extends MediaWikiTestCase {
                $b = new NothingClass();
 
                $wgHooks['MediaWikiHooksTest001'][] = $a;
-               $this->assertTrue( Hooks::isRegistered( 'MediaWikiHooksTest001' ), 'Hook registered via $wgHooks should be noticed by Hooks::isRegistered' );
+               $this->assertTrue(
+                       Hooks::isRegistered( 'MediaWikiHooksTest001' ),
+                       'Hook registered via $wgHooks should be noticed by Hooks::isRegistered'
+               );
 
                Hooks::register( 'MediaWikiHooksTest001', $b );
-               $this->assertEquals( 2, count( Hooks::getHandlers( 'MediaWikiHooksTest001' ) ), 'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register' );
+               $this->assertEquals(
+                       2,
+                       count( Hooks::getHandlers( 'MediaWikiHooksTest001' ) ),
+                       'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register'
+               );
 
                $foo = 'quux';
                $bar = 'qaax';
 
                Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
-               $this->assertEquals( 1, $a->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' );
-               $this->assertEquals( 1, $b->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' );
+               $this->assertEquals(
+                       1,
+                       $a->calls,
+                       'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
+               );
+               $this->assertEquals(
+                       1,
+                       $b->calls,
+                       'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
+               );
        }
 
        /**
index 98eff7b..10ccc4f 100644 (file)
@@ -8,7 +8,9 @@ class HtmlFormatterTest extends MediaWikiTestCase {
         * @dataProvider getHtmlData
         * @covers HtmlFormatter::getText
         */
-       public function testTransform( $input, $expectedText, $expectedRemoved = array(), $callback = false ) {
+       public function testTransform( $input, $expectedText,
+               $expectedRemoved = array(), $callback = false
+       ) {
                $input = self::normalize( $input );
                $formatter = new HtmlFormatter( HtmlFormatter::wrapHTML( $input ) );
                if ( $callback ) {
@@ -56,9 +58,11 @@ class HtmlFormatterTest extends MediaWikiTestCase {
                        ),
                        // basic tag removal
                        array(
+                               // @codingStandardsIgnoreStart Ignore long line warnings.
                                '<table><tr><td>foo</td></tr></table><div class="foo">foo</div><div class="foo quux">foo</div><span id="bar">bar</span>
 <strong class="foo" id="bar">foobar</strong><div class="notfoo">test</div><div class="baz"/>
 <span class="baz">baz</span>',
+                               // @codingStandardsIgnoreEnd
                                '<div class="notfoo">test</div>
 <span class="baz">baz</span>',
                                array(
@@ -92,8 +96,10 @@ class HtmlFormatterTest extends MediaWikiTestCase {
                        ),
                        // https://bugzilla.wikimedia.org/show_bug.cgi?id=53086
                        array(
-                               'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup> <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
-                               'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup> <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
+                               'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>'
+                                       . ' <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
+                               'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>'
+                                       . ' <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
                        ),
                );
        }
index 21372a0..f112a00 100644 (file)
@@ -590,7 +590,8 @@ class HtmlTest extends MediaWikiTestCase {
                # see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
                $cases[] = array( '<button type=submit></button>',
                        'button', array( 'type' => 'submit' ),
-                       'According to standard the default type is "submit". Depending on compatibility mode IE might use "button", instead.',
+                       'According to standard the default type is "submit". '
+                               . 'Depending on compatibility mode IE might use "button", instead.',
                );
 
                # <select> specifc handling
@@ -640,13 +641,25 @@ class HtmlTest extends MediaWikiTestCase {
         */
        public function testFormValidationBlacklist() {
                $this->assertEmpty(
-                       Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 2 ) ),
+                       Html::expandAttributes( array(
+                               'min' => 1,
+                               'max' => 100,
+                               'pattern' => 'abc',
+                               'required' => true,
+                               'step' => 2
+                       ) ),
                        'Blacklist form validation attributes.'
                );
                $this->assertEquals(
                        ' step=any',
-                       Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 'any' ) ),
+                       Html::expandAttributes( array(
+                               'min' => 1,
+                               'max' => 100,
+                               'pattern' => 'abc',
+                               'required' => true,
+                               'step' => 'any'
+                       ) ,
                        'Allow special case "step=any".'
-               );
+               ) );
        }
 }
index 11d8ed6..9b53381 100644 (file)
@@ -177,7 +177,6 @@ class HttpTest extends MediaWikiTestCase {
  * Class to let us overwrite MWHttpRequest respHeaders variable
  */
 class MWHttpRequestTester extends MWHttpRequest {
-
        // function derived from the MWHttpRequest factory function but
        // returns appropriate tester class here
        public static function factory( $url, $options = null ) {
@@ -193,8 +192,9 @@ class MWHttpRequestTester extends MWHttpRequest {
                                return new CurlHttpRequestTester( $url, $options );
                        case 'php':
                                if ( !wfIniGetBool( 'allow_url_fopen' ) ) {
-                                       throw new MWException( __METHOD__ . ': allow_url_fopen needs to be enabled for pure PHP' .
-                                               ' http requests to work. If possible, curl should be used instead. See http://php.net/curl.' );
+                                       throw new MWException( __METHOD__ .
+                                               ': allow_url_fopen needs to be enabled for pure PHP HTTP requests to work. '
+                                                       . 'If possible, curl should be used instead. See http://php.net/curl.' );
                                }
 
                                return new PhpHttpRequestTester( $url, $options );
index 351ad34..110cbac 100644 (file)
@@ -28,38 +28,52 @@ class LinkerTest extends MediaWikiLangTestCase {
 
                        ### ANONYMOUS USER ########################################
                        array(
-                               '<a href="/wiki/Special:Contributions/JohnDoe" title="Special:Contributions/JohnDoe" class="mw-userlink mw-anonuserlink">JohnDoe</a>',
+                               '<a href="/wiki/Special:Contributions/JohnDoe" '
+                                       . 'title="Special:Contributions/JohnDoe" '
+                                       . 'class="mw-userlink mw-anonuserlink">JohnDoe</a>',
                                0, 'JohnDoe', false,
                        ),
                        array(
-                               '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink mw-anonuserlink">::1</a>',
+                               '<a href="/wiki/Special:Contributions/::1" '
+                                       . 'title="Special:Contributions/::1" '
+                                       . 'class="mw-userlink mw-anonuserlink">::1</a>',
                                0, '::1', false,
                                'Anonymous with pretty IPv6'
                        ),
                        array(
-                               '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" title="Special:Contributions/0:0:0:0:0:0:0:1" class="mw-userlink mw-anonuserlink">::1</a>',
+                               '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" '
+                                       . 'title="Special:Contributions/0:0:0:0:0:0:0:1" '
+                                       . 'class="mw-userlink mw-anonuserlink">::1</a>',
                                0, '0:0:0:0:0:0:0:1', false,
                                'Anonymous with almost pretty IPv6'
                        ),
                        array(
-                               '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" class="mw-userlink mw-anonuserlink">::1</a>',
+                               '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" '
+                                       . 'title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" '
+                                       . 'class="mw-userlink mw-anonuserlink">::1</a>',
                                0, '0000:0000:0000:0000:0000:0000:0000:0001', false,
                                'Anonymous with full IPv6'
                        ),
                        array(
-                               '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
+                               '<a href="/wiki/Special:Contributions/::1" '
+                                       . 'title="Special:Contributions/::1" '
+                                       . 'class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
                                0, '::1', 'AlternativeUsername',
                                'Anonymous with pretty IPv6 and an alternative username'
                        ),
 
                        # IPV4
                        array(
-                               '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink mw-anonuserlink">127.0.0.1</a>',
+                               '<a href="/wiki/Special:Contributions/127.0.0.1" '
+                                       . 'title="Special:Contributions/127.0.0.1" '
+                                       . 'class="mw-userlink mw-anonuserlink">127.0.0.1</a>',
                                0, '127.0.0.1', false,
                                'Anonymous with IPv4'
                        ),
                        array(
-                               '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
+                               '<a href="/wiki/Special:Contributions/127.0.0.1" '
+                                       . 'title="Special:Contributions/127.0.0.1" '
+                                       . 'class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
                                0, '127.0.0.1', 'AlternativeUsername',
                                'Anonymous with IPv4 and an alternative username'
                        ),
index 33643ac..941beed 100644 (file)
@@ -63,9 +63,15 @@ class LinksUpdateTest extends MediaWikiTestCase {
                $po->addLink( Title::newFromText( "linksupdatetest:Foo" ) ); // interwiki link should be ignored
                $po->addLink( Title::newFromText( "#Foo" ) ); // hash link should be ignored
 
-               $update = $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
-                       array( NS_MAIN, 'Foo' ),
-               ) );
+               $update = $this->assertLinksUpdate(
+                       $t,
+                       $po,
+                       'pagelinks',
+                       'pl_namespace,
+                       pl_title',
+                       'pl_from = 111',
+                       array( array( NS_MAIN, 'Foo' ) )
+               );
                $this->assertArrayEquals( array(
                        Title::makeTitle( NS_MAIN, 'Foo' ),  // newFromText doesn't yield the same internal state....
                ), $update->getAddedLinks() );
@@ -76,10 +82,18 @@ class LinksUpdateTest extends MediaWikiTestCase {
                $po->addLink( Title::newFromText( "Bar" ) );
                $po->addLink( Title::newFromText( "Talk:Bar" ) );
 
-               $update = $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
-                       array( NS_MAIN, 'Bar' ),
-                       array( NS_TALK, 'Bar' ),
-               ) );
+               $update = $this->assertLinksUpdate(
+                       $t,
+                       $po,
+                       'pagelinks',
+                       'pl_namespace,
+                       pl_title',
+                       'pl_from = 111',
+                       array(
+                               array( NS_MAIN, 'Bar' ),
+                               array( NS_TALK, 'Bar' ),
+                       )
+               );
                $this->assertArrayEquals( array(
                        Title::makeTitle( NS_MAIN, 'Bar' ),
                        Title::makeTitle( NS_TALK, 'Bar' ),
@@ -143,9 +157,15 @@ class LinksUpdateTest extends MediaWikiTestCase {
 
                $po->addTemplate( Title::newFromText( "Template:Foo" ), 23, 42 );
 
-               $this->assertLinksUpdate( $t, $po, 'templatelinks', 'tl_namespace, tl_title', 'tl_from = 111', array(
-                       array( NS_TEMPLATE, 'Foo' ),
-               ) );
+               $this->assertLinksUpdate(
+                       $t,
+                       $po,
+                       'templatelinks',
+                       'tl_namespace,
+                       tl_title',
+                       'tl_from = 111',
+                       array( array( NS_TEMPLATE, 'Foo' ) )
+               );
        }
 
        /**
@@ -192,7 +212,9 @@ class LinksUpdateTest extends MediaWikiTestCase {
 
        // @todo test recursive, too!
 
-       protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows ) {
+       protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput,
+               $table, $fields, $condition, array $expectedRows
+       ) {
                $update = new LinksUpdate( $title, $parserOutput );
 
                //NOTE: make sure LinksUpdate does not generate warnings when called inside a transaction.
index b6fa139..49fdd48 100644 (file)
@@ -572,7 +572,11 @@ class MWNamespaceTest extends MediaWikiTestCase {
                        return $this->$method( $args );
                }
 
-               if ( preg_match( '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/', $method, $m ) ) {
+               if ( preg_match(
+                       '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
+                       $method,
+                       $m
+               ) ) {
                        # Interprets arguments:
                        $ns = $args[0];
                        $msg = isset( $args[1] ) ? $args[1] : " dummy message";