| Index: trunk/phase3/maintenance/tests/phpunit/includes/parser/ParserHelpers.php |
| — | — | @@ -33,6 +33,7 @@ |
| 34 | 34 | $result = new PHPUnit_Framework_TestResult; |
| 35 | 35 | } |
| 36 | 36 | |
| | 37 | + $this->suite->publishTestArticles(); // Add articles needed by the tests. |
| 37 | 38 | $backend = new ParserTestSuiteBackend; |
| 38 | 39 | $result->startTest( $this ); |
| 39 | 40 | |
| Index: trunk/phase3/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php |
| — | — | @@ -4,8 +4,9 @@ |
| 5 | 5 | require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' ); |
| 6 | 6 | |
| 7 | 7 | class MediaWikiParserTest extends MediaWikiTestSetup { |
| 8 | | - public $count; |
| 9 | | - public $backend; |
| | 8 | + public $count; // Number of tests in the suite. |
| | 9 | + public $backend; // ParserTestSuiteBackend instance |
| | 10 | + public $articles = array(); // Array of test articles defined by the tests |
| 10 | 11 | |
| 11 | 12 | public function __construct() { |
| 12 | 13 | $suite = new PHPUnit_Framework_TestSuite('Parser Tests'); |
| — | — | @@ -24,7 +25,7 @@ |
| 25 | 26 | $tester->count = 0; |
| 26 | 27 | |
| 27 | 28 | foreach ( $iter as $test ) { |
| 28 | | - $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Broken' ) ); |
| | 29 | + $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) ); |
| 29 | 30 | $tester->count++; |
| 30 | 31 | } |
| 31 | 32 | |
| — | — | @@ -46,5 +47,24 @@ |
| 47 | 48 | public function getIterator() { |
| 48 | 49 | return $this->iterator; |
| 49 | 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 ); |
| | 62 | + } |
| | 63 | + } |
| | 64 | + $this->articles = array(); |
| | 65 | + } |
| | 66 | + |
| | 67 | + public function addArticle( $name, $text, $line ) { |
| | 68 | + $this->articles[$name] = $text; |
| | 69 | + } |
| 50 | 70 | } |
| 51 | 71 | |
| Index: trunk/phase3/maintenance/tests/testHelpers.inc |
| — | — | @@ -536,10 +536,11 @@ |
| 537 | 537 | wfDie( "'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" ); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | | - $title = Title::newFromText( ParserTest::chomp( $data['article'] ) ); |
| 541 | | - $aid = $title->getArticleID( Title::GAID_FOR_UPDATE ); |
| 542 | | - if ( $aid == 0 ) |
| | 540 | + if ( $this->parser ) { |
| | 541 | + $this->parser->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum ); |
| | 542 | + } else { |
| 543 | 543 | ParserTest::addArticle( $data['article'], $data['text'], $this->lineNum ); |
| | 544 | + } |
| 544 | 545 | $data = array(); |
| 545 | 546 | $section = null; |
| 546 | 547 | |
| Index: trunk/phase3/maintenance/tests/parser/parserTest.inc |
| — | — | @@ -1154,7 +1154,7 @@ |
| 1155 | 1155 | * @param $text String: the article text |
| 1156 | 1156 | * @param $line Integer: the input line number, for reporting errors |
| 1157 | 1157 | */ |
| 1158 | | - static public function addArticle( $name, $text, $line ) { |
| | 1158 | + static public function addArticle( $name, $text, $line = 'unknown' ) { |
| 1159 | 1159 | global $wgCapitalLinks; |
| 1160 | 1160 | |
| 1161 | 1161 | $text = self::chomp($text); |