2 require_once __DIR__
. '/NewParserTest.php';
5 * The UnitTest must be either a class that inherits from MediaWikiTestCase
6 * or a class that provides a public static suite() method which returns
7 * an PHPUnit_Framework_Test object
12 class MediaWikiParserTest
{
14 public static function suite() {
15 global $wgParserTestFiles;
17 $suite = new PHPUnit_Framework_TestSuite
;
19 foreach ( $wgParserTestFiles as $fileName ) {
20 $testsName = basename( $fileName, '.txt' );
21 $escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) );
22 /* This used to be ucfirst( basename( dirname( $filename ) ) )
23 * and then was ucfirst( basename( $filename, '.txt' )
24 * but that didn't work with names like foo.tests.txt
26 $parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) );
27 $parserTestClassDefinition = <<<EOT
32 * @group ParserTests_$parserTestClassName
34 class $parserTestClassName extends NewParserTest {
35 protected \$file = '$escapedFileName';
39 eval( $parserTestClassDefinition );
41 $parserTester = new $parserTestClassName( $testsName );
42 $suite->addTestSuite( new ReflectionClass ( $parserTester ) );