Index: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php |
— | — | @@ -3,72 +3,62 @@ |
4 | 4 | require_once( dirname( __FILE__ ) . '/ParserHelpers.php' ); |
5 | 5 | require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' ); |
6 | 6 | |
| 7 | +/** |
| 8 | + * @group Parser |
| 9 | + * @group Destructive |
| 10 | + * @group Database |
| 11 | + */ |
7 | 12 | class MediaWikiParserTest extends MediaWikiTestCase { |
8 | 13 | public $count; // Number of tests in the suite. |
9 | | - public $backend; // ParserTestSuiteBackend instance |
10 | 14 | public $articles = array(); // Array of test articles defined by the tests |
11 | | - |
12 | | - public function __construct() { |
13 | | - parent::__construct(); |
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 | | - $tester->suite = new PHPUnit_Framework_TestSuite('Parser Tests'); |
| 15 | + protected $pt; |
| 16 | + |
| 17 | + function setUp() { |
| 18 | + global $wgContLang; |
| 19 | + $wgContLang = Language::factory( 'en' ); |
23 | 20 | |
24 | | - //Fixme: Use all the wgParserTestFiles (or whatever that global was...) |
25 | | - $iter = new TestFileIterator( "$IP/tests/parser/parserTests.txt", $tester ); |
26 | | - $tester->count = 0; |
27 | | - |
28 | | - foreach ( $iter as $test ) { |
29 | | - $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) ); |
30 | | - $tester->count++; |
| 21 | + $this->pt = new PHPUnitParserTest; |
| 22 | + $this->pt->setupDatabase(); |
| 23 | + |
| 24 | + } |
| 25 | + |
| 26 | + function tearDown() { |
| 27 | + if( is_object( $this->pt ) && $this->pt instanceof PHPUnitParserTest ) { |
| 28 | + $this->pt->teardownDatabase(); |
| 29 | + $this->pt = null; |
31 | 30 | } |
32 | | - |
33 | | - return $tester->suite; |
34 | 31 | } |
35 | 32 | |
36 | | - public function count() { |
37 | | - return $this->count; |
38 | | - } |
39 | | - |
40 | | - public function toString() { |
41 | | - return "MediaWiki Parser Tests"; |
42 | | - } |
43 | | - |
44 | | - public function getBackend() { |
45 | | - return $this->backend; |
46 | | - } |
47 | | - |
48 | | - public function getIterator() { |
49 | | - return $this->iterator; |
50 | | - } |
51 | | - |
52 | | - public function publishTestArticles() { |
53 | | - if ( empty( $this->articles ) ) { |
54 | | - return; |
55 | | - } |
56 | | - |
57 | | - foreach ( $this->articles as $name => $text ) { |
58 | | - $title = Title::newFromText( $name ); |
59 | | - |
60 | | - if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) { |
61 | | - ParserTest::addArticle( $name, $text ); |
| 33 | + |
| 34 | + public function testParserTests() { |
| 35 | + //global $IP; |
| 36 | + //$wgParserTestFiles = array( "$IP/tests/parser/testparserTests.txt" ); |
| 37 | + |
| 38 | + global $wgParserTestFiles; |
| 39 | + |
| 40 | + foreach( $wgParserTestFiles as $file ) { |
| 41 | + |
| 42 | + $iter = new TestFileIterator( $file, $this->pt ); |
| 43 | + |
| 44 | + try { |
| 45 | + foreach( $iter as $test ) { |
| 46 | + $r = $this->pt->runTest( $test['test'], $test['input'], |
| 47 | + $test['result'], $test['options'], $test['config'] |
| 48 | + ); |
| 49 | + |
| 50 | + $this->assertTrue( $r, 'Parser test ' . $test['test'] ); |
| 51 | + |
| 52 | + } |
| 53 | + } |
| 54 | + catch( DBQueryError $e ) { |
| 55 | + $this->assertTrue( false, 'Parser test ' . $test['test'] . ' (error: "' . $e->getMessage() . '")' ); |
| 56 | + //This is annoying... it always stops on error and doesn't go to the next one. |
| 57 | + continue; |
62 | 58 | } |
| 59 | + |
63 | 60 | } |
64 | | - $this->articles = array(); |
| 61 | + |
65 | 62 | } |
66 | 63 | |
67 | | - public function addArticle( $name, $text, $line ) { |
68 | | - $this->articles[$name] = $text; |
69 | | - } |
70 | | - |
71 | | - public function showRunFile( $path ) { |
72 | | - /* Nothing shown when run from phpunit */ |
73 | | - } |
74 | 64 | } |
75 | 65 | |