summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/parser/MediaWikiParserTest.php
blob: 067a7c4e7f09865eb937221b4cbed63db42c5d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once( __DIR__ . '/NewParserTest.php' );

/**
 * The UnitTest must be either a class that inherits from MediaWikiTestCase
 * or a class that provides a public static suite() method which returns
 * an PHPUnit_Framework_Test object
 *
 * @group Parser
 * @group Database
 */
class MediaWikiParserTest {

	public static function suite() {
		global $wgParserTestFiles;

		$suite = new PHPUnit_Framework_TestSuite;

		foreach ( $wgParserTestFiles as $filename ) {
			$testsName = basename( $filename, '.txt' );
			/* 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 ) );

			eval( "/** @group Database\n@group Parser\n*/ class $className extends NewParserTest { protected \$file = '" . strtr( $filename, array( "'" => "\\'", '\\' => '\\\\' ) ) . "'; } " );

			$parserTester = new $className( $testsName );
			$suite->addTestSuite( new ReflectionClass ( $parserTester ) );
		}
		return $suite;
	}
}