Pass phpcs-strict on some test files (6/11)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 24 Apr 2014 16:06:21 +0000 (18:06 +0200)
committerSiebrand <siebrand@kitano.nl>
Thu, 24 Apr 2014 18:26:19 +0000 (18:26 +0000)
Change-Id: I5f4bc0df8183cf338ff45cacfc7279c2cd38ee04

tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php
tests/phpunit/includes/content/ContentHandlerTest.php
tests/phpunit/includes/content/JavaScriptContentTest.php
tests/phpunit/includes/content/TextContentTest.php
tests/phpunit/includes/content/WikitextContentHandlerTest.php
tests/phpunit/includes/content/WikitextContentTest.php
tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
tests/phpunit/includes/db/DatabaseSQLTest.php
tests/phpunit/includes/db/DatabaseSqliteTest.php
tests/phpunit/includes/db/DatabaseTest.php

index 59b8d20..3f887dc 100644 (file)
@@ -59,7 +59,9 @@ class ComposerVersionNormalizerTest extends PHPUnit_Framework_TestCase {
        /**
         * @dataProvider complexVersionProvider
         */
-       public function testGivenComplexVersionWithoutDash_normalizeSuffixAddsDash( $withoutDash, $withDash ) {
+       public function testGivenComplexVersionWithoutDash_normalizeSuffixAddsDash(
+               $withoutDash, $withDash
+       ) {
                $normalizer = new ComposerVersionNormalizer();
 
                $this->assertEquals(
@@ -83,7 +85,9 @@ class ComposerVersionNormalizerTest extends PHPUnit_Framework_TestCase {
        /**
         * @dataProvider complexVersionProvider
         */
-       public function testGivenComplexVersionWithDash_normalizeSuffixReturnsAsIs( $withoutDash, $withDash ) {
+       public function testGivenComplexVersionWithDash_normalizeSuffixReturnsAsIs(
+               $withoutDash, $withDash
+       ) {
                $this->assertRemainsUnchanged( $withDash );
        }
 
@@ -114,7 +118,9 @@ class ComposerVersionNormalizerTest extends PHPUnit_Framework_TestCase {
        /**
         * @dataProvider levelNormalizationProvider
         */
-       public function testGivenFewerLevels_levelCountNormalizationEnsuresFourLevels( $expected, $version ) {
+       public function testGivenFewerLevels_levelCountNormalizationEnsuresFourLevels(
+               $expected, $version
+       ) {
                $normalizer = new ComposerVersionNormalizer();
 
                $this->assertEquals(
index f21aad8..ecfcfa3 100644 (file)
@@ -4,9 +4,9 @@
  * @group ContentHandler
  * @group Database
  *
- * @note Declare that we are using the database, because otherwise we'll fail in the "databaseless" test run.
- * This is because the LinkHolderArray used by the parser needs database access.
- *
+ * @note Declare that we are using the database, because otherwise we'll fail in
+ * the "databaseless" test run. This is because the LinkHolderArray used by the
+ * parser needs database access.
  */
 class ContentHandlerTest extends MediaWikiTestCase {
 
@@ -238,13 +238,45 @@ class ContentHandlerTest extends MediaWikiTestCase {
                        array( 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
                        array( serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", 'hallo', false ),
 
-                       array( 'hallo', 'Help:Test', null, CONTENT_FORMAT_WIKITEXT, CONTENT_MODEL_WIKITEXT, 'hallo', false ),
-                       array( 'hallo', 'MediaWiki:Test.js', null, CONTENT_FORMAT_JAVASCRIPT, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
+                       array(
+                               'hallo',
+                               'Help:Test',
+                               null,
+                               CONTENT_FORMAT_WIKITEXT,
+                               CONTENT_MODEL_WIKITEXT,
+                               'hallo',
+                               false
+                       ),
+                       array(
+                               'hallo',
+                               'MediaWiki:Test.js',
+                               null,
+                               CONTENT_FORMAT_JAVASCRIPT,
+                               CONTENT_MODEL_JAVASCRIPT,
+                               'hallo',
+                               false
+                       ),
                        array( serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", 'hallo', false ),
 
                        array( 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ),
-                       array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ),
-                       array( serialize( 'hallo' ), 'Dummy:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, serialize( 'hallo' ), false ),
+                       array(
+                               'hallo',
+                               'MediaWiki:Test.js',
+                               CONTENT_MODEL_CSS,
+                               null,
+                               CONTENT_MODEL_CSS,
+                               'hallo',
+                               false
+                       ),
+                       array(
+                               serialize( 'hallo' ),
+                               'Dummy:Test',
+                               CONTENT_MODEL_CSS,
+                               null,
+                               CONTENT_MODEL_CSS,
+                               serialize( 'hallo' ),
+                               false
+                       ),
 
                        array( 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ),
                        array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ),
@@ -256,7 +288,9 @@ class ContentHandlerTest extends MediaWikiTestCase {
         * @dataProvider dataMakeContent
         * @covers ContentHandler::makeContent
         */
-       public function testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail ) {
+       public function testMakeContent( $data, $title, $modelId, $format,
+               $expectedModelId, $expectedNativeData, $shouldFail
+       ) {
                $title = Title::newFromText( $title );
 
                try {
@@ -291,7 +325,11 @@ class ContentHandlerTest extends MediaWikiTestCase {
                Hooks::register( 'testRunLegacyHooks', __CLASS__ . '::dummyHookHandler' );
 
                $content = new WikitextContent( 'test text' );
-               $ok = ContentHandler::runLegacyHooks( 'testRunLegacyHooks', array( 'foo', &$content, 'bar' ), false );
+               $ok = ContentHandler::runLegacyHooks(
+                       'testRunLegacyHooks',
+                       array( 'foo', &$content, 'bar' ),
+                       false
+               );
 
                $this->assertTrue( $ok, "runLegacyHooks should have returned true" );
                $this->assertEquals( "TEST TEXT", $content->getNativeData() );
@@ -362,8 +400,9 @@ class DummyContentForTesting extends AbstractContent {
        }
 
        /**
-        * @return string A string representing the content in a way useful for building a full text search index.
-        *   If no useful representation exists, this method returns an empty string.
+        * @return string A string representing the content in a way useful for
+        *   building a full text search index. If no useful representation exists,
+        *   this method returns an empty string.
         */
        public function getTextForSearchIndex() {
                return '';
@@ -378,7 +417,8 @@ class DummyContentForTesting extends AbstractContent {
        }
 
        /**
-        * Returns a textual representation of the content suitable for use in edit summaries and log messages.
+        * Returns a textual representation of the content suitable for use in edit
+        * summaries and log messages.
         *
         * @param int $maxlength Maximum length of the summary text.
         * @return string The summary text.
@@ -429,8 +469,8 @@ class DummyContentForTesting extends AbstractContent {
         * Returns true if this content is countable as a "real" wiki page, provided
         * that it's also in a countable location (e.g. a current revision in the main namespace).
         *
-        * @param bool $hasLinks if it is known whether this content contains links, provide this information here,
-        *  to avoid redundant parsing to find out.
+        * @param bool $hasLinks if it is known whether this content contains links,
+        * provide this information here, to avoid redundant parsing to find out.
         * @return bool
         */
        public function isCountable( $hasLinks = null ) {
@@ -446,7 +486,9 @@ class DummyContentForTesting extends AbstractContent {
         *
         * @return ParserOutput
         */
-       public function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
+       public function getParserOutput( Title $title, $revId = null,
+               ParserOptions $options = null, $generateHtml = true
+       ) {
                return new ParserOutput( $this->getNativeData() );
        }
 }
index c8616ff..7193ec9 100644 (file)
@@ -243,7 +243,10 @@ class JavaScriptContentTest extends TextContentTest {
                $mw = MagicWord::get( "staticredirect" );
 
                $content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
-               $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word, since it's not wikitext" );
+               $this->assertFalse(
+                       $content->matchMagicWord( $mw ),
+                       "should not have matched magic word, since it's not wikitext"
+               );
        }
 
        /**
@@ -255,7 +258,10 @@ class JavaScriptContentTest extends TextContentTest {
                $content = $this->newContent( "#REDIRECT [[Someplace]]" );
                $newContent = $content->updateRedirect( $target );
 
-               $this->assertTrue( $content->equals( $newContent ), "content should be unchanged since it's not wikitext" );
+               $this->assertTrue(
+                       $content->equals( $newContent ),
+                       "content should be unchanged since it's not wikitext"
+               );
        }
 
        /**
index a1f099f..253a035 100644 (file)
@@ -53,7 +53,9 @@ class TextContentTest extends MediaWikiLangTestCase {
         * @dataProvider dataGetParserOutput
         * @covers TextContent::getParserOutput
         */
-       public function testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields = null ) {
+       public function testGetParserOutput( $title, $model, $text, $expectedHtml,
+               $expectedFields = null
+       ) {
                $title = Title::newFromText( $title );
                $content = ContentHandler::makeContent( $text, $title, $model );
 
@@ -105,7 +107,11 @@ class TextContentTest extends MediaWikiLangTestCase {
                $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), $wgContLang );
 
                $content = $this->newContent( $text );
-               $content = $content->preSaveTransform( $this->context->getTitle(), $this->context->getUser(), $options );
+               $content = $content->preSaveTransform(
+                       $this->context->getTitle(),
+                       $this->context->getUser(),
+                       $options
+               );
 
                $this->assertEquals( $expected, $content->getNativeData() );
        }
@@ -223,8 +229,13 @@ class TextContentTest extends MediaWikiLangTestCase {
 
                $v = $content->isCountable( $hasLinks, $this->context->getTitle() );
 
-               $this->assertEquals( $expected, $v, 'isCountable() returned unexpected value ' . var_export( $v, true )
-                       . ' instead of ' . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+               $this->assertEquals(
+                       $expected,
+                       $v,
+                       'isCountable() returned unexpected value ' . var_export( $v, true )
+                               . ' instead of ' . var_export( $expected, true )
+                               . " in mode `$mode` for text \"$text\""
+               );
        }
 
        public static function dataGetTextForSummary() {
index 73b975b..38fb573 100644 (file)
@@ -4,11 +4,10 @@
  * @group ContentHandler
  */
 class WikitextContentHandlerTest extends MediaWikiLangTestCase {
-
        /**
         * @var ContentHandler
         */
-       var $handler;
+       private $handler;
 
        protected function setUp() {
                parent::setUp();
@@ -23,7 +22,10 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
                $content = new WikitextContent( 'hello world' );
 
                $this->assertEquals( 'hello world', $this->handler->serializeContent( $content ) );
-               $this->assertEquals( 'hello world', $this->handler->serializeContent( $content, CONTENT_FORMAT_WIKITEXT ) );
+               $this->assertEquals(
+                       'hello world',
+                       $this->handler->serializeContent( $content, CONTENT_FORMAT_WIKITEXT )
+               );
 
                try {
                        $this->handler->serializeContent( $content, 'dummy/foo' );
@@ -98,7 +100,10 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
                        array( 'Category:Foo', '#REDIRECT [[:Category:Foo]]' ),
                        array( Title::makeTitle( NS_MAIN, 'en:Foo' ), '#REDIRECT [[en:Foo]]' ),
                        array( Title::makeTitle( NS_MAIN, 'Foo', '', 'en' ), '#REDIRECT [[:en:Foo]]' ),
-                       array( Title::makeTitle( NS_MAIN, 'Bar', 'fragment', 'google' ), '#REDIRECT [[google:Bar#fragment]]' ),
+                       array(
+                               Title::makeTitle( NS_MAIN, 'Bar', 'fragment', 'google' ),
+                               '#REDIRECT [[google:Bar#fragment]]'
+                       ),
                );
        }
 
@@ -183,9 +188,10 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
                        ),
 
                        array(
-                               'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
-                               labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et
-                               ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
+                               'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
+                               eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
+                               voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
+                               clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
                                'Hello world!',
                                0,
                                '/^Replaced .*Hello/'
@@ -210,7 +216,10 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
 
                $summary = $this->handler->getAutosummary( $oldContent, $newContent, $flags );
 
-               $this->assertTrue( (bool)preg_match( $expected, $summary ), "Autosummary didn't match expected pattern $expected: $summary" );
+               $this->assertTrue(
+                       (bool)preg_match( $expected, $summary ),
+                       "Autosummary didn't match expected pattern $expected: $summary"
+               );
        }
 
        /**
@@ -224,6 +233,9 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
         * @todo Text case requires database, should be done by a test class in the Database group
         */
        /*
-       public function testGetUndoContent( Revision $current, Revision $undo, Revision $undoafter = null ) {}
+       public function testGetUndoContent( Revision $current, Revision $undo,
+               Revision $undoafter = null
+       ) {
+       }
        */
 }
index 1d133f3..bd4ae35 100644 (file)
@@ -7,7 +7,7 @@
  *        ^--- needed, because we do need the database to test link updates
  */
 class WikitextContentTest extends TextContentTest {
-       static $sections = "Intro
+       public static $sections = "Intro
 
 == stuff ==
 hello world
@@ -150,7 +150,10 @@ just a test"
                                "2",
                                "== TEST ==\nmore fun",
                                null,
-                               trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", WikitextContentTest::$sections ) )
+                               trim( preg_replace(
+                                       '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==",
+                                       WikitextContentTest::$sections
+                               ) )
                        ),
                        array( WikitextContentTest::$sections,
                                "8",
index 516ce3a..55e48d1 100644 (file)
  */
 class FakeDatabaseMysqlBase extends DatabaseMysqlBase {
        // From DatabaseBase
-       function __construct() {}
-       protected function closeConnection() {}
-       protected function doQuery( $sql ) {}
+       function __construct() {
+       }
+
+       protected function closeConnection() {
+       }
+
+       protected function doQuery( $sql ) {
+       }
 
        // From DatabaseMysql
-       protected function mysqlConnect( $realServer ) {}
-       protected function mysqlSetCharset( $charset ) {}
-       protected function mysqlFreeResult( $res ) {}
-       protected function mysqlFetchObject( $res ) {}
-       protected function mysqlFetchArray( $res ) {}
-       protected function mysqlNumRows( $res ) {}
-       protected function mysqlNumFields( $res ) {}
-       protected function mysqlFieldName( $res, $n ) {}
-       protected function mysqlFieldType( $res, $n ) {}
-       protected function mysqlDataSeek( $res, $row ) {}
-       protected function mysqlError( $conn = null ) {}
-       protected function mysqlFetchField( $res, $n ) {}
-       protected function mysqlPing() {}
+       protected function mysqlConnect( $realServer ) {
+       }
+
+       protected function mysqlSetCharset( $charset ) {
+       }
+
+       protected function mysqlFreeResult( $res ) {
+       }
+
+       protected function mysqlFetchObject( $res ) {
+       }
+
+       protected function mysqlFetchArray( $res ) {
+       }
+
+       protected function mysqlNumRows( $res ) {
+       }
+
+       protected function mysqlNumFields( $res ) {
+       }
+
+       protected function mysqlFieldName( $res, $n ) {
+       }
+
+       protected function mysqlFieldType( $res, $n ) {
+       }
+
+       protected function mysqlDataSeek( $res, $row ) {
+       }
+
+       protected function mysqlError( $conn = null ) {
+       }
+
+       protected function mysqlFetchField( $res, $n ) {
+       }
+
+       protected function mysqlPing() {
+       }
 
        // From interface DatabaseType
-       function insertId() {}
-       function lastErrno() {}
-       function affectedRows() {}
-       function getServerVersion() {}
+       function insertId() {
+       }
+
+       function lastErrno() {
+       }
+
+       function affectedRows() {
+       }
+
+       function getServerVersion() {
+       }
 }
 
 class DatabaseMysqlBaseTest extends MediaWikiTestCase {
-
        /**
         * @dataProvider provideDiapers
         * @covers DatabaseMysqlBase::addIdentifierQuotes
index bdd567e..5c2d4b7 100644 (file)
@@ -101,7 +101,11 @@ class DatabaseSQLTest extends MediaWikiTestCase {
                                        'tables' => array( 'table', 't2' => 'table2' ),
                                        'fields' => array( 'tid', 'field', 'alias' => 'field2', 't2.id' ),
                                        'conds' => array( 'alias' => 'text' ),
-                                       'options' => array( 'LIMIT' => 1, 'GROUP BY' => array( 'field', 'field2' ), 'HAVING' => array( 'COUNT(*) > 1', 'field' => 1 ) ),
+                                       'options' => array(
+                                               'LIMIT' => 1,
+                                               'GROUP BY' => array( 'field', 'field2' ),
+                                               'HAVING' => array( 'COUNT(*) > 1', 'field' => 1 )
+                                       ),
                                        'join_conds' => array( 't2' => array(
                                                'LEFT JOIN', 'tid = t2.id'
                                        ) ),
index 65726eb..b4c1953 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 class MockDatabaseSqlite extends DatabaseSqliteStandalone {
-       var $lastQuery;
+       private $lastQuery;
 
        function __construct() {
                parent::__construct( ':memory:' );
@@ -27,11 +27,8 @@ class MockDatabaseSqlite extends DatabaseSqliteStandalone {
  * @group medium
  */
 class DatabaseSqliteTest extends MediaWikiTestCase {
-
-       /**
-        * @var MockDatabaseSqlite
-        */
-       var $db;
+       /** @var MockDatabaseSqlite */
+       protected $db;
 
        protected function setUp() {
                parent::setUp();
@@ -74,7 +71,8 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
                        array( // #2: including quote
                                'foo\'bar', "'foo''bar'"
                        ),
-                       array( // #3: including \0 (must be represented as hex, per https://bugs.php.net/bug.php?id=63419)
+                       // #3: including \0 (must be represented as hex, per https://bugs.php.net/bug.php?id=63419)
+                       array(
                                "x\0y",
                                "x'780079'",
                        ),
@@ -116,14 +114,21 @@ class DatabaseSqliteTest extends MediaWikiTestCase {
        public function testReplaceVars() {
                $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
 
-               $this->assertEquals( "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
+               $this->assertEquals(
+                       "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
                                . "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
-                       $this->replaceVars( "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
-                       foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;" )
+                       $this->replaceVars(
+                               "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, "
+                               . "foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', "
+                               . "foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;"
+                       )
                );
 
-               $this->assertEquals( "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
-                       $this->replaceVars( "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );" )
+               $this->assertEquals(
+                       "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
+                       $this->replaceVars(
+                               "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );"
+                       )
                );
 
                $this->assertEquals( "CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
index 35a8e4c..7e70439 100644 (file)
@@ -8,8 +8,9 @@ class DatabaseTest extends MediaWikiTestCase {
        /**
         * @var DatabaseBase
         */
-       var $db;
-       var $functionTest = false;
+       protected $db;
+
+       private $functionTest = false;
 
        protected function setUp() {
                parent::setUp();
@@ -215,7 +216,9 @@ class DatabaseTest extends MediaWikiTestCase {
                global $IP;
                $this->dropFunctions();
                $this->functionTest = true;
-               $this->assertTrue( $this->db->sourceFile( "$IP/tests/phpunit/data/db/{$this->db->getType()}/functions.sql" ) );
+               $this->assertTrue(
+                       $this->db->sourceFile( "$IP/tests/phpunit/data/db/{$this->db->getType()}/functions.sql" )
+               );
                $res = $this->db->query( 'SELECT mw_test_function() AS test', __METHOD__ );
                $this->assertEquals( 42, $res->fetchObject()->test );
        }