phpcs: More require/include is not a function
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / MediaWikiParserTest.php
1 <?php
2 require_once __DIR__ . '/NewParserTest.php';
3
4 /**
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
8 *
9 * @group Parser
10 * @group Database
11 */
12 class MediaWikiParserTest {
13
14 public static function suite() {
15 global $wgParserTestFiles;
16
17 $suite = new PHPUnit_Framework_TestSuite;
18
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
25 */
26 $parserTestClassName = str_replace( '.', '_', ucfirst( $testsName ) );
27 $parserTestClassDefinition = <<<EOT
28 /**
29 * @group Database
30 * @group Parser
31 * @group ParserTests
32 * @group ParserTests_$parserTestClassName
33 */
34 class $parserTestClassName extends NewParserTest {
35 protected \$file = '$escapedFileName';
36 }
37 EOT;
38
39 eval( $parserTestClassDefinition );
40
41 $parserTester = new $parserTestClassName( $testsName );
42 $suite->addTestSuite( new ReflectionClass ( $parserTester ) );
43 }
44
45 return $suite;
46 }
47 }