From: Daniel Werner Date: Sat, 20 Apr 2013 20:22:26 +0000 (+0200) Subject: Improved readability of MediaWikiParserTest::suite code X-Git-Tag: 1.31.0-rc.0~19920^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=93e7bc4c44bd7477c12a1e1c77172a85f2fabc15;p=lhc%2Fweb%2Fwiklou.git Improved readability of MediaWikiParserTest::suite code Change-Id: Ic74048bcce71c2eeb8adfca872b978c3f0de094b --- diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php index 067a7c4e7f..c5c7cf2079 100644 --- a/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php @@ -16,17 +16,27 @@ class MediaWikiParserTest { $suite = new PHPUnit_Framework_TestSuite; - foreach ( $wgParserTestFiles as $filename ) { - $testsName = basename( $filename, '.txt' ); + foreach ( $wgParserTestFiles as $fileName ) { + $testsName = basename( $fileName, '.txt' ); + $escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) ); /* This used to be ucfirst( basename( dirname( $filename ) ) ) * and then was ucfirst( basename( $filename, '.txt' ) * but that didn't work with names like foo.tests.txt */ - $className = str_replace( '.', '_', ucfirst( $testsName ) ); + $parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) ); + $parserTestClassDefinition = << "\\'", '\\' => '\\\\' ) ) . "'; } " ); + eval( $parserTestClassDefinition ); - $parserTester = new $className( $testsName ); + $parserTester = new $parserTestClassName( $testsName ); $suite->addTestSuite( new ReflectionClass ( $parserTester ) ); } return $suite;