From 7b931bcce82e74835db68188e2d273f502a5a8dc Mon Sep 17 00:00:00 2001 From: Platonides Date: Fri, 5 Nov 2010 22:14:45 +0000 Subject: [PATCH] Rename TestFileIterator $parser member. It is unrelated with the Parser object. Too much similar names here. What do you drink with your articles? A ParserTest or a MediaWikiParserTest? Removed the redundant setParser() method. --- .../includes/parser/MediaWikiParserTest.php | 7 ++-- maintenance/tests/testHelpers.inc | 34 ++++++++----------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php b/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php index a8d105ab06..3825a8fabf 100644 --- a/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ b/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php @@ -20,8 +20,7 @@ class MediaWikiParserTest extends MediaWikiTestSetup { $tester = new self; - $iter = new TestFileIterator( "$IP/maintenance/tests/parser/parserTests.txt" ); - $iter->setParser( $tester ); + $iter = new TestFileIterator( "$IP/maintenance/tests/parser/parserTests.txt", $tester ); $tester->count = 0; foreach ( $iter as $test ) { @@ -66,5 +65,9 @@ class MediaWikiParserTest extends MediaWikiTestSetup { public function addArticle( $name, $text, $line ) { $this->articles[$name] = $text; } + + public function showRunFile( $path ) { + /* Nothing shown when run from phpunit */ + } } diff --git a/maintenance/tests/testHelpers.inc b/maintenance/tests/testHelpers.inc index 71479e570f..24172e457b 100644 --- a/maintenance/tests/testHelpers.inc +++ b/maintenance/tests/testHelpers.inc @@ -453,13 +453,13 @@ class RemoteTestRecorder extends TestRecorder { 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; @@ -469,19 +469,15 @@ class TestFileIterator implements Iterator { 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" ); @@ -536,9 +532,9 @@ class TestFileIterator implements Iterator { 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(); @@ -556,7 +552,7 @@ class TestFileIterator implements Iterator { $line = trim( $line ); if ( $line ) { - if ( $this->parser && !$this->parser->requireHook( $line ) ) { + if ( $this->parserTest && !$this->parserTest->requireHook( $line ) ) { return false; } } @@ -577,7 +573,7 @@ class TestFileIterator implements Iterator { $line = trim( $line ); if ( $line ) { - if ( $this->parser && !$this->parser->requireFunctionHook( $line ) ) { + if ( $this->parserTest && !$this->parserTest->requireFunctionHook( $line ) ) { return false; } } @@ -609,9 +605,9 @@ class TestFileIterator implements Iterator { 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; @@ -621,7 +617,7 @@ class TestFileIterator implements Iterator { 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(); @@ -630,7 +626,7 @@ class TestFileIterator implements Iterator { continue; } - if ( $this->parser ) { + if ( $this->parserTest ) { $this->test = array( 'test' => ParserTest::chomp( $data['test'] ), 'input' => ParserTest::chomp( $data['input'] ), -- 2.20.1