2011-05-31 20:30:12 +00:00
|
|
|
<?php
|
2012-08-27 19:03:15 +00:00
|
|
|
require_once( __DIR__ . '/NewParserTest.php' );
|
2011-05-31 20:30:12 +00:00
|
|
|
|
|
|
|
|
/**
|
2011-11-12 21:32:39 +00:00
|
|
|
* The UnitTest must be either a class that inherits from MediaWikiTestCase
|
2013-02-15 10:24:31 +00:00
|
|
|
* or a class that provides a public static suite() method which returns
|
2011-05-31 20:30:12 +00:00
|
|
|
* an PHPUnit_Framework_Test object
|
2013-02-15 10:24:31 +00:00
|
|
|
*
|
2011-05-31 20:30:12 +00:00
|
|
|
* @group Parser
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
|
|
|
|
class MediaWikiParserTest {
|
|
|
|
|
|
|
|
|
|
public static function suite() {
|
|
|
|
|
global $wgParserTestFiles;
|
|
|
|
|
|
|
|
|
|
$suite = new PHPUnit_Framework_TestSuite;
|
|
|
|
|
|
2013-04-20 20:22:26 +00:00
|
|
|
foreach ( $wgParserTestFiles as $fileName ) {
|
|
|
|
|
$testsName = basename( $fileName, '.txt' );
|
|
|
|
|
$escapedFileName = strtr( $fileName, array( "'" => "\\'", '\\' => '\\\\' ) );
|
2011-09-18 03:32:43 +00:00
|
|
|
/* 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
|
|
|
|
|
*/
|
2013-04-20 20:22:26 +00:00
|
|
|
$parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) );
|
|
|
|
|
$parserTestClassDefinition = <<<EOT
|
|
|
|
|
/**
|
|
|
|
|
* @group Database
|
|
|
|
|
* @group Parser
|
2013-04-20 20:28:38 +00:00
|
|
|
* @group ParserTests
|
|
|
|
|
* @group ParserTests_$parserTestClassName
|
2013-04-20 20:22:26 +00:00
|
|
|
*/
|
|
|
|
|
class $parserTestClassName extends NewParserTest {
|
|
|
|
|
protected \$file = '$escapedFileName';
|
|
|
|
|
}
|
|
|
|
|
EOT;
|
2012-12-07 01:11:38 +00:00
|
|
|
|
2013-04-20 20:22:26 +00:00
|
|
|
eval( $parserTestClassDefinition );
|
2011-05-31 20:30:12 +00:00
|
|
|
|
2013-04-20 20:22:26 +00:00
|
|
|
$parserTester = new $parserTestClassName( $testsName );
|
2011-05-31 20:30:12 +00:00
|
|
|
$suite->addTestSuite( new ReflectionClass ( $parserTester ) );
|
|
|
|
|
}
|
2013-04-26 12:00:22 +00:00
|
|
|
|
2011-05-31 20:30:12 +00:00
|
|
|
return $suite;
|
|
|
|
|
}
|
|
|
|
|
}
|