class TestFileIterator implements Iterator {
private $file;
private $fh;
- private $parser;
+ private $parserTest; /* An instance of ParserTest (parserTests.php) or MediaWikiParserTest (phpunit) */
private $index = 0;
private $test;
private $lineNum;
private $eof;
- function __construct( $file, $parser = null ) {
+ function __construct( $file, $parserTest = null ) {
global $IP;
$this->file = $file;
wfDie( "Couldn't open file '$file'\n" );
}
- $this->parser = $parser;
+ $this->parserTest = $parserTest;
- if ( $this->parser ) {
- $this->parser->showRunFile( wfRelativePath( $this->file, $IP ) );
+ if ( $this->parserTest ) {
+ $this->parserTest->showRunFile( wfRelativePath( $this->file, $IP ) );
}
$this->lineNum = $this->index = 0;
}
- function setParser( MediaWikiParserTest $parser ) {
- $this->parser = $parser;
- }
-
function rewind() {
if ( fseek( $this->fh, 0 ) ) {
wfDie( "Couldn't fseek to the start of '$this->file'\n" );
wfDie( "'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" );
}
- if ( $this->parser ) {
- $this->parser->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum );
- } else {
+ if ( $this->parserTest ) {
+ $this->parserTest->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum );
+ } else {wfDie("JAJA");
ParserTest::addArticle( $data['article'], $data['text'], $this->lineNum );
}
$data = array();
$line = trim( $line );
if ( $line ) {
- if ( $this->parser && !$this->parser->requireHook( $line ) ) {
+ if ( $this->parserTest && !$this->parserTest->requireHook( $line ) ) {
return false;
}
}
$line = trim( $line );
if ( $line ) {
- if ( $this->parser && !$this->parser->requireFunctionHook( $line ) ) {
+ if ( $this->parserTest && !$this->parserTest->requireFunctionHook( $line ) ) {
return false;
}
}
if ( !isset( $data['config'] ) )
$data['config'] = '';
- if ( $this->parser
- && ( ( preg_match( '/\\bdisabled\\b/i', $data['options'] ) && !$this->parser->runDisabled )
- || !preg_match( "/" . $this->parser->regex . "/i", $data['test'] ) ) ) {
+ if ( $this->parserTest
+ && ( ( preg_match( '/\\bdisabled\\b/i', $data['options'] ) && !$this->parserTest->runDisabled )
+ || !preg_match( "/" . $this->parserTest->regex . "/i", $data['test'] ) ) ) {
# disabled test
$data = array();
$section = null;
global $wgUseTeX;
- if ( $this->parser &&
+ if ( $this->parserTest &&
preg_match( '/\\bmath\\b/i', $data['options'] ) && !$wgUseTeX ) {
# don't run math tests if $wgUseTeX is set to false in LocalSettings
$data = array();
continue;
}
- if ( $this->parser ) {
+ if ( $this->parserTest ) {
$this->test = array(
'test' => ParserTest::chomp( $data['test'] ),
'input' => ParserTest::chomp( $data['input'] ),