r79184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79183‎ | r79184 | r79185 >
Date:16:40, 29 December 2010
Author:soxred93
Status:ok
Tags:
Comment:
Self-reverting my reversion of r79154 in r79158. The old version is flawed and broken beyond belief. At least this version works.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
@@ -3,72 +3,62 @@
44 require_once( dirname( __FILE__ ) . '/ParserHelpers.php' );
55 require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
66
 7+/**
 8+ * @group Parser
 9+ * @group Destructive
 10+ * @group Database
 11+ */
712 class MediaWikiParserTest extends MediaWikiTestCase {
813 public $count; // Number of tests in the suite.
9 - public $backend; // ParserTestSuiteBackend instance
1014 public $articles = array(); // Array of test articles defined by the tests
11 -
12 - public function __construct() {
13 - parent::__construct();
14 - $this->backend = new ParserTestSuiteBackend;
15 - $this->setName( 'Parser tests' );
16 - }
17 -
18 - public static function suite() {
19 - global $IP;
20 -
21 - $tester = new self;
22 - $tester->suite = new PHPUnit_Framework_TestSuite('Parser Tests');
 15+ protected $pt;
 16+
 17+ function setUp() {
 18+ global $wgContLang;
 19+ $wgContLang = Language::factory( 'en' );
2320
24 - //Fixme: Use all the wgParserTestFiles (or whatever that global was...)
25 - $iter = new TestFileIterator( "$IP/tests/parser/parserTests.txt", $tester );
26 - $tester->count = 0;
27 -
28 - foreach ( $iter as $test ) {
29 - $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
30 - $tester->count++;
 21+ $this->pt = new PHPUnitParserTest;
 22+ $this->pt->setupDatabase();
 23+
 24+ }
 25+
 26+ function tearDown() {
 27+ if( is_object( $this->pt ) && $this->pt instanceof PHPUnitParserTest ) {
 28+ $this->pt->teardownDatabase();
 29+ $this->pt = null;
3130 }
32 -
33 - return $tester->suite;
3431 }
3532
36 - public function count() {
37 - return $this->count;
38 - }
39 -
40 - public function toString() {
41 - return "MediaWiki Parser Tests";
42 - }
43 -
44 - public function getBackend() {
45 - return $this->backend;
46 - }
47 -
48 - public function getIterator() {
49 - return $this->iterator;
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 );
 33+
 34+ public function testParserTests() {
 35+ //global $IP;
 36+ //$wgParserTestFiles = array( "$IP/tests/parser/testparserTests.txt" );
 37+
 38+ global $wgParserTestFiles;
 39+
 40+ foreach( $wgParserTestFiles as $file ) {
 41+
 42+ $iter = new TestFileIterator( $file, $this->pt );
 43+
 44+ try {
 45+ foreach( $iter as $test ) {
 46+ $r = $this->pt->runTest( $test['test'], $test['input'],
 47+ $test['result'], $test['options'], $test['config']
 48+ );
 49+
 50+ $this->assertTrue( $r, 'Parser test ' . $test['test'] );
 51+
 52+ }
 53+ }
 54+ catch( DBQueryError $e ) {
 55+ $this->assertTrue( false, 'Parser test ' . $test['test'] . ' (error: "' . $e->getMessage() . '")' );
 56+ //This is annoying... it always stops on error and doesn't go to the next one.
 57+ continue;
6258 }
 59+
6360 }
64 - $this->articles = array();
 61+
6562 }
6663
67 - public function addArticle( $name, $text, $line ) {
68 - $this->articles[$name] = $text;
69 - }
70 -
71 - public function showRunFile( $path ) {
72 - /* Nothing shown when run from phpunit */
73 - }
7464 }
7565

Follow-up revisions

RevisionCommit summaryAuthorDate
r82867Finally commit the testing stuff I have been with this week. Could be conside...platonides21:49, 26 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79154Make MediaWikiParserTest work now in PHPUnit. There are still a few bugs, suc...soxred9302:23, 29 December 2010
r79158Partial revert of r79154. hexmode asserts that these work, even though I keep...soxred9303:35, 29 December 2010

Status & tagging log