Per wikitech-l discussion: Move tests from maintenance/tests/ to tests/. They're...
[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 MediaWikiTestSetup {
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 $suite = new PHPUnit_Framework_TestSuite('Parser Tests');
13 parent::__construct($suite);
14 $this->backend = new ParserTestSuiteBackend;
15 $this->setName( 'Parser tests' );
16 }
17
18 public static function suite() {
19 global $IP;
20
21 $tester = new self;
22
23 $iter = new TestFileIterator( "$IP/maintenance/tests/parser/parserTests.txt", $tester );
24 $tester->count = 0;
25
26 foreach ( $iter as $test ) {
27 $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
28 $tester->count++;
29 }
30
31 return $tester->suite;
32 }
33
34 public function count() {
35 return $this->count;
36 }
37
38 public function toString() {
39 return "MediaWiki Parser Tests";
40 }
41
42 public function getBackend() {
43 return $this->backend;
44 }
45
46 public function getIterator() {
47 return $this->iterator;
48 }
49
50 public function publishTestArticles() {
51 if ( empty( $this->articles ) ) {
52 return;
53 }
54
55 foreach ( $this->articles as $name => $text ) {
56 $title = Title::newFromText( $name );
57
58 if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) {
59 ParserTest::addArticle( $name, $text );
60 }
61 }
62 $this->articles = array();
63 }
64
65 public function addArticle( $name, $text, $line ) {
66 $this->articles[$name] = $text;
67 }
68
69 public function showRunFile( $path ) {
70 /* Nothing shown when run from phpunit */
71 }
72 }
73