From ce42915e0dac8c93684b68faf1707f6b577b96b0 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 24 Apr 2014 12:05:52 +0200 Subject: [PATCH] Pass phpcs-strict on some test files (2/x) Change-Id: Ia39fd107a554206927652b6e168faa0da501b362 --- tests/phpunit/includes/FallbackTest.php | 6 +-- tests/phpunit/includes/FauxRequestTest.php | 1 - tests/phpunit/includes/FauxResponseTest.php | 48 ++++++++++++++++---- tests/phpunit/includes/HooksTest.php | 44 +++++++++++++++--- tests/phpunit/includes/HtmlFormatterTest.php | 12 +++-- tests/phpunit/includes/HtmlTest.php | 21 +++++++-- tests/phpunit/includes/HttpTest.php | 6 +-- tests/phpunit/includes/LinkerTest.php | 28 +++++++++--- tests/phpunit/includes/LinksUpdateTest.php | 44 +++++++++++++----- tests/phpunit/includes/MWNamespaceTest.php | 6 ++- 10 files changed, 168 insertions(+), 48 deletions(-) diff --git a/tests/phpunit/includes/FallbackTest.php b/tests/phpunit/includes/FallbackTest.php index 910b766f7c..c60170f3e5 100644 --- a/tests/phpunit/includes/FallbackTest.php +++ b/tests/phpunit/includes/FallbackTest.php @@ -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"; diff --git a/tests/phpunit/includes/FauxRequestTest.php b/tests/phpunit/includes/FauxRequestTest.php index 3246410f09..745a5b42f1 100644 --- a/tests/phpunit/includes/FauxRequestTest.php +++ b/tests/phpunit/includes/FauxRequestTest.php @@ -1,7 +1,6 @@ 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' + ); } } diff --git a/tests/phpunit/includes/HooksTest.php b/tests/phpunit/includes/HooksTest.php index 87af6c1f3b..74d4b09131 100644 --- a/tests/phpunit/includes/HooksTest.php +++ b/tests/phpunit/includes/HooksTest.php @@ -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' + ); } /** diff --git a/tests/phpunit/includes/HtmlFormatterTest.php b/tests/phpunit/includes/HtmlFormatterTest.php index 98eff7b387..10ccc4fa29 100644 --- a/tests/phpunit/includes/HtmlFormatterTest.php +++ b/tests/phpunit/includes/HtmlFormatterTest.php @@ -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. '
foo
foo
foo
bar foobar
test
baz', + // @codingStandardsIgnoreEnd '
test
baz', array( @@ -92,8 +96,10 @@ class HtmlFormatterTest extends MediaWikiTestCase { ), // https://bugzilla.wikimedia.org/show_bug.cgi?id=53086 array( - 'Foo[1] Bar', - 'Foo[1] Bar', + 'Foo[1]' + . ' Bar', + 'Foo[1]' + . ' Bar', ), ); } diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 21372a0816..f112a0080e 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -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', 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.', ); #