Pass phpcs-strict on some test files (1/x)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 09:57:41 +0000 (11:57 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 15:05:32 +0000 (17:05 +0200)
Change-Id: I7f8dee09ac734cbc369441431841f2d4aa5d7f51

tests/phpunit/MediaWikiLangTestCase.php
tests/phpunit/MediaWikiPHPUnitTestListener.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/ResourceLoaderTestCase.php
tests/phpunit/includes/ArticleTest.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/EditPageTest.php
tests/phpunit/includes/ExternalStoreTest.php
tests/phpunit/includes/ExtraParserTest.php

index 1131385..53e6722 100644 (file)
@@ -4,7 +4,6 @@
  * Base class that store and restore the Language objects
  */
 abstract class MediaWikiLangTestCase extends MediaWikiTestCase {
-
        protected function setUp() {
                global $wgLanguageCode, $wgContLang;
                parent::setUp();
index c8ec411..9eeb251 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
 
+class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
        /**
         * @var string
         */
@@ -35,7 +35,10 @@ class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
         * @param float $time
         */
        public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
-               wfDebugLog( $this->logChannel, 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+               wfDebugLog(
+                       $this->logChannel,
+                       'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+               );
        }
 
        /**
@@ -45,8 +48,13 @@ class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
         * @param PHPUnit_Framework_AssertionFailedError $e
         * @param float $time
         */
-       public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
-               wfDebugLog( $this->logChannel, 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+       public function addFailure( PHPUnit_Framework_Test $test,
+               PHPUnit_Framework_AssertionFailedError $e, $time
+       ) {
+               wfDebugLog(
+                       $this->logChannel,
+                       'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+               );
        }
 
        /**
@@ -57,7 +65,10 @@ class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
         * @param float $time
         */
        public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
-               wfDebugLog( $this->logChannel, 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+               wfDebugLog(
+                       $this->logChannel,
+                       'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+               );
        }
 
        /**
@@ -70,7 +81,10 @@ class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
         * @since Method available since Release 3.0.0
         */
        public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
-               wfDebugLog( $this->logChannel, 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+               wfDebugLog(
+                       $this->logChannel,
+                       'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+               );
        }
 
        /**
index 1c9b7fb..53b944d 100644 (file)
@@ -4,7 +4,6 @@
  * @since 1.18
  */
 abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
-
        /**
         * $called tracks whether the setUp and tearDown method has been called.
         * class extending MediaWikiTestCase usually override setUp and tearDown
@@ -254,7 +253,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
 
                        $oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
                        $newHex = strtoupper( dechex( $phpErrorLevel ) );
-                       $message = "PHP error_reporting setting was left dirty: was 0x$oldHex before test, 0x$newHex after test!";
+                       $message = "PHP error_reporting setting was left dirty: "
+                               . "was 0x$oldHex before test, 0x$newHex after test!";
 
                        $this->fail( $message );
                }
@@ -772,7 +772,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         * @param bool $ordered If the order of the values should match
         * @param bool $named If the keys should match
         */
-       protected function assertArrayEquals( array $expected, array $actual, $ordered = false, $named = false ) {
+       protected function assertArrayEquals( array $expected, array $actual,
+               $ordered = false, $named = false
+       ) {
                if ( !$ordered ) {
                        $this->objectAssociativeSort( $expected );
                        $this->objectAssociativeSort( $actual );
@@ -1105,5 +1107,4 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
 
                $this->assertEmpty( $errors, implode( "\n", $errors ) );
        }
-
 }
index a03e9cc..f8c4c6c 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
 abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
-
        protected static function getResourceLoaderContext() {
                $resourceLoader = new ResourceLoader();
                $request = new FauxRequest( array(
@@ -40,7 +39,6 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
 /* Stubs */
 
 class ResourceLoaderTestModule extends ResourceLoaderModule {
-
        protected $dependencies = array();
        protected $group = null;
        protected $source = 'local';
@@ -65,4 +63,5 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
        }
 }
 
-class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {}
+class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {
+}
index 84f900f..b07c013 100644 (file)
@@ -66,7 +66,9 @@ class ArticleTest extends MediaWikiTestCase {
        }
 
        /**
-        * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
+        * Checks for the existence of the backwards compatibility static functions
+        * (forwarders to WikiPage class)
+        *
         * @covers Article::selectFields
         * @covers Article::onArticleCreate
         * @covers Article::onArticleDelete
index 480d7d2..b248d24 100644 (file)
@@ -72,14 +72,20 @@ class BlockTest extends MediaWikiLangTestCase {
         * @covers Block::newFromTarget
         */
        public function testINewFromTargetReturnsCorrectBlock() {
-               $this->assertTrue( $this->block->equals( Block::newFromTarget( 'UTBlockee' ) ), "newFromTarget() returns the same block as the one that was made" );
+               $this->assertTrue(
+                       $this->block->equals( Block::newFromTarget( 'UTBlockee' ) ),
+                       "newFromTarget() returns the same block as the one that was made"
+               );
        }
 
        /**
         * @covers Block::newFromID
         */
        public function testINewFromIDReturnsCorrectBlock() {
-               $this->assertTrue( $this->block->equals( Block::newFromID( $this->blockId ) ), "newFromID() returns the same block as the one that was made" );
+               $this->assertTrue(
+                       $this->block->equals( Block::newFromID( $this->blockId ) ),
+                       "newFromID() returns the same block as the one that was made"
+               );
        }
 
        /**
@@ -88,7 +94,11 @@ class BlockTest extends MediaWikiLangTestCase {
        public function testBug26425BlockTimestampDefaultsToTime() {
                // delta to stop one-off errors when things happen to go over a second mark.
                $delta = abs( $this->madeAt - $this->block->mTimestamp );
-               $this->assertLessThan( 2, $delta, "If no timestamp is specified, the block is recorded as time()" );
+               $this->assertLessThan(
+                       2,
+                       $delta,
+                       "If no timestamp is specified, the block is recorded as time()"
+               );
        }
 
        /**
@@ -101,7 +111,11 @@ class BlockTest extends MediaWikiLangTestCase {
         */
        public function testBug29116NewFromTargetWithEmptyIp( $vagueTarget ) {
                $block = Block::newFromTarget( 'UTBlockee', $vagueTarget );
-               $this->assertTrue( $this->block->equals( $block ), "newFromTarget() returns the same block as the one that was made when given empty vagueTarget param " . var_export( $vagueTarget, true ) );
+               $this->assertTrue(
+                       $this->block->equals( $block ),
+                       "newFromTarget() returns the same block as the one that was made when "
+                               . "given empty vagueTarget param " . var_export( $vagueTarget, true )
+               );
        }
 
        public static function provideBug29116Data() {
@@ -215,7 +229,11 @@ class BlockTest extends MediaWikiLangTestCase {
                $user = null; // clear
 
                $block = Block::newFromID( $res['id'] );
-               $this->assertEquals( 'UserOnForeignWiki', $block->getTarget()->getName(), 'Correct blockee name' );
+               $this->assertEquals(
+                       'UserOnForeignWiki',
+                       $block->getTarget()->getName(),
+                       'Correct blockee name'
+               );
                $this->assertEquals( '14146', $block->getTarget()->getId(), 'Correct blockee id' );
                $this->assertEquals( 'MetaWikiUser', $block->getBlocker(), 'Correct blocker name' );
                $this->assertEquals( 'MetaWikiUser', $block->getByName(), 'Correct blocker name' );
index 4da8448..3c653b4 100644 (file)
@@ -75,7 +75,8 @@ class EditPageTest extends MediaWikiLangTestCase {
         *              * wpTextbox1: the text to submit
         *              * wpSummary: the edit summary
         *              * wpEditToken: the edit token (will be inserted if not provided)
-        *              * wpEdittime: timestamp of the edit's base revision (will be inserted if not provided)
+        *              * wpEdittime: timestamp of the edit's base revision (will be inserted
+        *                if not provided)
         *              * wpStarttime: timestamp when the edit started (will be inserted if not provided)
         *              * wpSectionTitle: the section to edit
         *              * wpMinorEdit: mark as minor edit
@@ -474,8 +475,14 @@ hello
                }
 
                $starttime = wfTimestampNow();
-               $adamsTime = wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$adamsEdit['wpStarttime'] );
-               $bertasTime = wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$bertasEdit['wpStarttime'] );
+               $adamsTime = wfTimestamp(
+                       TS_MW,
+                       (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$adamsEdit['wpStarttime']
+               );
+               $bertasTime = wfTimestamp(
+                       TS_MW,
+                       (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$bertasEdit['wpStarttime']
+               );
 
                $adamsEdit['wpStarttime'] = $adamsTime;
                $bertasEdit['wpStarttime'] = $bertasTime;
index cd3364e..07c2957 100644 (file)
@@ -75,7 +75,10 @@ class ExternalStoreFOO {
                        return null;
                }
 
-               if ( $itemID !== false && is_array( $this->data[$cluster][$id] ) && isset( $this->data[$cluster][$id][$itemID] ) ) {
+               if ( $itemID !== false
+                       && is_array( $this->data[$cluster][$id] )
+                       && isset( $this->data[$cluster][$id][$itemID] )
+               ) {
                        return $this->data[$cluster][$id][$itemID];
                }
 
index 3cf7abd..4a4130e 100644 (file)
@@ -130,8 +130,16 @@ class ExtraParserTest extends MediaWikiTestCase {
         * @covers Parser::getSection
         */
        public function testGetSection() {
-               $outputText2 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 2 );
-               $outputText1 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1 );
+               $outputText2 = $this->parser->getSection(
+                       "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
+                               . "Section 2\n== Heading 3 ==\nSection 3\n",
+                       2
+               );
+               $outputText1 = $this->parser->getSection(
+                       "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
+                               . "Section 2\n== Heading 3 ==\nSection 3\n",
+                       1
+               );
 
                $this->assertEquals( "=== Heading 2 ===\nSection 2", $outputText2 );
                $this->assertEquals( "== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2", $outputText1 );
@@ -141,7 +149,12 @@ class ExtraParserTest extends MediaWikiTestCase {
         * @covers Parser::replaceSection
         */
        public function testReplaceSection() {
-               $outputText = $this->parser->replaceSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1, "New section 1" );
+               $outputText = $this->parser->replaceSection(
+                       "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
+                               . "Section 2\n== Heading 3 ==\nSection 3\n",
+                       1,
+                       "New section 1"
+               );
 
                $this->assertEquals( "Section 0\nNew section 1\n\n== Heading 3 ==\nSection 3", $outputText );
        }
@@ -152,7 +165,11 @@ class ExtraParserTest extends MediaWikiTestCase {
         */
        public function testGetPreloadText() {
                $title = Title::newFromText( __FUNCTION__ );
-               $outputText = $this->parser->getPreloadText( "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->", $title, $this->options );
+               $outputText = $this->parser->getPreloadText(
+                       "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->",
+                       $title,
+                       $this->options
+               );
 
                $this->assertEquals( "{{Foo}} information <!-- is very secret -->", $outputText );
        }