r79158 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79157‎ | r79158 | r79159 >
Date:03:35, 29 December 2010
Author:soxred93
Status:reverted
Tags:
Comment:
Partial revert of r79154. hexmode asserts that these work, even though I keep getting OK (0 tests, 0 assertions)
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php
@@ -4,20 +4,19 @@
55 function showTesting( $desc ) {
66 global $additionalMWCLIArgs;
77 if( $additionalMWCLIArgs['verbose'] ) parent::showTesting( $desc );
8 - //var_dump($options);
98 /* Do nothing since we don't want to show info during PHPUnit testing. */
109 }
1110
1211 public function showSuccess( $desc ) {
1312 global $additionalMWCLIArgs;
14 -
 13+ PHPUnit_Framework_Assert::assertTrue( true, $desc );
1514 if( $additionalMWCLIArgs['verbose'] ) parent::showSuccess( $desc );
1615 return true;
1716 }
1817
1918 public function showFailure( $desc, $expected, $got ) {
2019 global $additionalMWCLIArgs;
21 -
 20+ PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc );
2221 if( $additionalMWCLIArgs['verbose'] ) parent::showFailure( $desc, $expected, $got );
2322 return false;
2423 }
Index: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php
@@ -3,62 +3,72 @@
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 - */
127 class MediaWikiParserTest extends MediaWikiTestCase {
138 public $count; // Number of tests in the suite.
 9+ public $backend; // ParserTestSuiteBackend instance
1410 public $articles = array(); // Array of test articles defined by the tests
15 - protected $pt;
16 -
17 - function setUp() {
18 - global $wgContLang;
19 - $wgContLang = Language::factory( 'en' );
 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');
2023
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;
 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++;
3031 }
 32+
 33+ return $tester->suite;
3134 }
3235
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;
 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 );
5862 }
59 -
6063 }
61 -
 64+ $this->articles = array();
6265 }
6366
 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+ }
6474 }
6575

Follow-up revisions

RevisionCommit summaryAuthorDate
r79184Self-reverting my reversion of r79154 in r79158. The old version is flawed an...soxred9316:40, 29 December 2010

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

Status & tagging log