Partial revert of r79154. hexmode asserts that these work, even though I keep getting...
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / MediaWikiParserTest.php
1 <?php
2
3 require_once( dirname( __FILE__ ) . '/ParserHelpers.php' );
4 require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
5
6 class MediaWikiParserTest extends MediaWikiTestCase {
7 public $count; // Number of tests in the suite.
8 public $backend; // ParserTestSuiteBackend instance
9 public $articles = array(); // Array of test articles defined by the tests
10
11 public function __construct() {
12 parent::__construct();
13 $this->backend = new ParserTestSuiteBackend;
14 $this->setName( 'Parser tests' );
15 }
16
17 public static function suite() {
18 global $IP;
19
20 $tester = new self;
21 $tester->suite = new PHPUnit_Framework_TestSuite('Parser Tests');
22
23 //Fixme: Use all the wgParserTestFiles (or whatever that global was...)
24 $iter = new TestFileIterator( "$IP/tests/parser/parserTests.txt", $tester );
25 $tester->count = 0;
26
27 foreach ( $iter as $test ) {
28 $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
29 $tester->count++;
30 }
31
32 return $tester->suite;
33 }
34
35 public function count() {
36 return $this->count;
37 }
38
39 public function toString() {
40 return "MediaWiki Parser Tests";
41 }
42
43 public function getBackend() {
44 return $this->backend;
45 }
46
47 public function getIterator() {
48 return $this->iterator;
49 }
50
51 public function publishTestArticles() {
52 if ( empty( $this->articles ) ) {
53 return;
54 }
55
56 foreach ( $this->articles as $name => $text ) {
57 $title = Title::newFromText( $name );
58
59 if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) {
60 ParserTest::addArticle( $name, $text );
61 }
62 }
63 $this->articles = array();
64 }
65
66 public function addArticle( $name, $text, $line ) {
67 $this->articles[$name] = $text;
68 }
69
70 public function showRunFile( $path ) {
71 /* Nothing shown when run from phpunit */
72 }
73 }
74