From 715abaa6b6c1a7906ba6f9eb588c5123f0de6b4d Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Wed, 30 Sep 2015 09:08:31 +0300 Subject: [PATCH] Make lines short to pass phpcs in parser tests PHP files Bug: T102614 Change-Id: I14a28815af83efd38f04def8eb7d42ef124ab918 --- tests/phpunit/includes/parser/MediaWikiParserTest.php | 5 ++++- tests/phpunit/includes/parser/ParserMethodsTest.php | 3 ++- tests/phpunit/includes/parser/TagHooksTest.php | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php index 96ae3bec64..95822ad0ca 100644 --- a/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php @@ -94,9 +94,12 @@ class MediaWikiParserTest { $testsName = $extensionName . '__' . basename( $fileName, '.txt' ); $escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) ); $parserTestClassName = ucfirst( $testsName ); + // Official spec for class names: http://php.net/manual/en/language.oop5.basic.php // Prepend 'ParserTest_' to be paranoid about it not starting with a number - $parserTestClassName = 'ParserTest_' . preg_replace( '/[^a-zA-Z0-9_\x7f-\xff]/', '_', $parserTestClassName ); + $parserTestClassName = 'ParserTest_' . + preg_replace( '/[^a-zA-Z0-9_\x7f-\xff]/', '_', $parserTestClassName ); + if ( isset( $testList[$parserTestClassName] ) ) { // If a conflict happens, gives a very unclear fatal. // So as a last ditch effort to prevent that eventuality, if there diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php index af143caa8d..bf0eb109c4 100644 --- a/tests/phpunit/includes/parser/ParserMethodsTest.php +++ b/tests/phpunit/includes/parser/ParserMethodsTest.php @@ -71,7 +71,8 @@ class ParserMethodsTest extends MediaWikiLangTestCase { /** * @expectedException MWException - * @expectedExceptionMessage Parser state cleared while parsing. Did you call Parser::parse recursively? + * @expectedExceptionMessage Parser state cleared while parsing. + * Did you call Parser::parse recursively? * @covers Parser::lock */ public function testRecursiveParse() { diff --git a/tests/phpunit/includes/parser/TagHooksTest.php b/tests/phpunit/includes/parser/TagHooksTest.php index 4af389852a..672b1d4ba0 100644 --- a/tests/phpunit/includes/parser/TagHooksTest.php +++ b/tests/phpunit/includes/parser/TagHooksTest.php @@ -84,7 +84,11 @@ class TagHookTest extends MediaWikiTestCase { global $wgParserConf, $wgContLang; $parser = new Parser( $wgParserConf ); - $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), Parser::SFH_OBJECT_ARGS ); + $parser->setFunctionTagHook( + $tag, + array( $this, 'functionTagCallback' ), + Parser::SFH_OBJECT_ARGS + ); $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), -- 2.20.1