Make MediaWikiParserTest work now in PHPUnit. There are still a few bugs, such as...
[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 /**
7 * @group Parser
8 * @group Destructive
9 * @group Database
10 */
11 class MediaWikiParserTest extends MediaWikiTestCase {
12 public $count; // Number of tests in the suite.
13 public $articles = array(); // Array of test articles defined by the tests
14 protected $pt;
15
16 function setUp() {
17 global $wgContLang;
18 $wgContLang = Language::factory( 'en' );
19
20 $this->pt = new PHPUnitParserTest;
21 $this->pt->setupDatabase();
22
23 }
24
25 function tearDown() {
26 if( is_object( $this->pt ) && $this->pt instanceof PHPUnitParserTest ) {
27 $this->pt->teardownDatabase();
28 $this->pt = null;
29 }
30 }
31
32
33 public function testParserTests() {
34 //global $IP;
35 //$wgParserTestFiles = array( "$IP/tests/parser/testparserTests.txt" );
36
37 global $wgParserTestFiles;
38
39 foreach( $wgParserTestFiles as $file ) {
40
41 $iter = new TestFileIterator( $file, $this->pt );
42
43 try {
44 foreach( $iter as $test ) {
45 $r = $this->pt->runTest( $test['test'], $test['input'],
46 $test['result'], $test['options'], $test['config']
47 );
48
49 $this->assertTrue( $r, 'Parser test ' . $test['test'] );
50
51 }
52 }
53 catch( DBQueryError $e ) {
54 $this->assertTrue( false, 'Parser test ' . $test['test'] . ' (error: "' . $e->getMessage() . '")' );
55 //This is annoying... it always stops on error and doesn't go to the next one.
56 continue;
57 }
58
59 }
60
61 }
62
63 }
64