From: Siebrand Mazeland Date: Thu, 24 Apr 2014 16:06:21 +0000 (+0200) Subject: Pass phpcs-strict on some test files (6/11) X-Git-Tag: 1.31.0-rc.0~16032 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=1742e9448ce3c7b1590451c401ef09df2fa7e3f8;p=lhc%2Fweb%2Fwiklou.git Pass phpcs-strict on some test files (6/11) Change-Id: I5f4bc0df8183cf338ff45cacfc7279c2cd38ee04 --- diff --git a/tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php b/tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php index 59b8d20c15..3f887dc08c 100644 --- a/tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php +++ b/tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php @@ -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( diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php index f21aad817f..ecfcfa3e80 100644 --- a/tests/phpunit/includes/content/ContentHandlerTest.php +++ b/tests/phpunit/includes/content/ContentHandlerTest.php @@ -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() ); } } diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php index c8616ff006..7193ec9fac 100644 --- a/tests/phpunit/includes/content/JavaScriptContentTest.php +++ b/tests/phpunit/includes/content/JavaScriptContentTest.php @@ -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" + ); } /** diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index a1f099f31f..253a03542c 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -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() { diff --git a/tests/phpunit/includes/content/WikitextContentHandlerTest.php b/tests/phpunit/includes/content/WikitextContentHandlerTest.php index 73b975baa8..38fb57330c 100644 --- a/tests/phpunit/includes/content/WikitextContentHandlerTest.php +++ b/tests/phpunit/includes/content/WikitextContentHandlerTest.php @@ -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 + ) { + } */ } diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index 1d133f3236..bd4ae35d08 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -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", diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php index 516ce3a0d0..55e48d13c6 100644 --- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php +++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php @@ -31,34 +31,70 @@ */ 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 diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php b/tests/phpunit/includes/db/DatabaseSQLTest.php index bdd567e7f6..5c2d4b7045 100644 --- a/tests/phpunit/includes/db/DatabaseSQLTest.php +++ b/tests/phpunit/includes/db/DatabaseSQLTest.php @@ -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' ) ), diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php b/tests/phpunit/includes/db/DatabaseSqliteTest.php index 65726ebe84..b4c1953ebe 100644 --- a/tests/phpunit/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php @@ -1,7 +1,7 @@ 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 );", diff --git a/tests/phpunit/includes/db/DatabaseTest.php b/tests/phpunit/includes/db/DatabaseTest.php index 35a8e4cdba..7e70439656 100644 --- a/tests/phpunit/includes/db/DatabaseTest.php +++ b/tests/phpunit/includes/db/DatabaseTest.php @@ -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 ); }