From: X! Date: Wed, 29 Dec 2010 16:40:31 +0000 (+0000) Subject: Self-reverting my reversion of r79154 in r79158. The old version is flawed and broken... X-Git-Tag: 1.31.0-rc.0~33005 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=194ab8bb57213e08585d5454d2b0055b316e9dfd;p=lhc%2Fweb%2Fwiklou.git Self-reverting my reversion of r79154 in r79158. The old version is flawed and broken beyond belief. At least this version works. --- diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php index ce7f770410..fcc10a89f3 100644 --- a/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php @@ -3,72 +3,62 @@ require_once( dirname( __FILE__ ) . '/ParserHelpers.php' ); require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' ); +/** + * @group Parser + * @group Destructive + * @group Database + */ class MediaWikiParserTest extends MediaWikiTestCase { 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() { - parent::__construct(); - $this->backend = new ParserTestSuiteBackend; - $this->setName( 'Parser tests' ); - } - - public static function suite() { - global $IP; - - $tester = new self; - $tester->suite = new PHPUnit_Framework_TestSuite('Parser Tests'); + protected $pt; + + function setUp() { + global $wgContLang; + $wgContLang = Language::factory( 'en' ); + + $this->pt = new PHPUnitParserTest; + $this->pt->setupDatabase(); - //Fixme: Use all the wgParserTestFiles (or whatever that global was...) - $iter = new TestFileIterator( "$IP/tests/parser/parserTests.txt", $tester ); - $tester->count = 0; - - foreach ( $iter as $test ) { - $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) ); - $tester->count++; - } - - return $tester->suite; - } - - public function count() { - return $this->count; - } - - public function toString() { - return "MediaWiki Parser Tests"; - } - - public function getBackend() { - return $this->backend; - } - - public function getIterator() { - return $this->iterator; } - - public function publishTestArticles() { - if ( empty( $this->articles ) ) { - return; + + function tearDown() { + if( is_object( $this->pt ) && $this->pt instanceof PHPUnitParserTest ) { + $this->pt->teardownDatabase(); + $this->pt = null; } + } - foreach ( $this->articles as $name => $text ) { - $title = Title::newFromText( $name ); - - if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) { - ParserTest::addArticle( $name, $text ); + + public function testParserTests() { + //global $IP; + //$wgParserTestFiles = array( "$IP/tests/parser/testparserTests.txt" ); + + global $wgParserTestFiles; + + foreach( $wgParserTestFiles as $file ) { + + $iter = new TestFileIterator( $file, $this->pt ); + + try { + foreach( $iter as $test ) { + $r = $this->pt->runTest( $test['test'], $test['input'], + $test['result'], $test['options'], $test['config'] + ); + + $this->assertTrue( $r, 'Parser test ' . $test['test'] ); + + } + } + catch( DBQueryError $e ) { + $this->assertTrue( false, 'Parser test ' . $test['test'] . ' (error: "' . $e->getMessage() . '")' ); + //This is annoying... it always stops on error and doesn't go to the next one. + continue; } + } - $this->articles = array(); - } - - public function addArticle( $name, $text, $line ) { - $this->articles[$name] = $text; + } - public function showRunFile( $path ) { - /* Nothing shown when run from phpunit */ - } }