* @param $text String: the article text
* @param $line Integer: the input line number, for reporting errors
*/
- static public function addArticle( $name, $text, $line ) {
+ static public function addArticle( $name, $text, $line = 'unknown' ) {
global $wgCapitalLinks;
$text = self::chomp($text);
require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
class MediaWikiParserTest extends MediaWikiTestSetup {
- public $count;
- public $backend;
+ public $count; // Number of tests in the suite.
+ public $backend; // ParserTestSuiteBackend instance
+ public $articles = array(); // Array of test articles defined by the tests
public function __construct() {
$suite = new PHPUnit_Framework_TestSuite('Parser Tests');
$tester->count = 0;
foreach ( $iter as $test ) {
- $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Broken' ) );
+ $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
$tester->count++;
}
public function getIterator() {
return $this->iterator;
}
+
+ public function publishTestArticles() {
+ if ( empty( $this->articles ) ) {
+ return;
+ }
+
+ foreach ( $this->articles as $name => $text ) {
+ $title = Title::newFromText( $name );
+
+ if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) {
+ ParserTest::addArticle( $name, $text );
+ }
+ }
+ $this->articles = array();
+ }
+
+ public function addArticle( $name, $text, $line ) {
+ $this->articles[$name] = $text;
+ }
}
wfDie( "'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" );
}
- $title = Title::newFromText( ParserTest::chomp( $data['article'] ) );
- $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
- if ( $aid == 0 )
+ if ( $this->parser ) {
+ $this->parser->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum );
+ } else {
ParserTest::addArticle( $data['article'], $data['text'], $this->lineNum );
+ }
$data = array();
$section = null;