Index: trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php |
— | — | @@ -4,20 +4,19 @@ |
5 | 5 | function showTesting( $desc ) { |
6 | 6 | global $additionalMWCLIArgs; |
7 | 7 | if( $additionalMWCLIArgs['verbose'] ) parent::showTesting( $desc ); |
8 | | - //var_dump($options); |
9 | 8 | /* Do nothing since we don't want to show info during PHPUnit testing. */ |
10 | 9 | } |
11 | 10 | |
12 | 11 | public function showSuccess( $desc ) { |
13 | 12 | global $additionalMWCLIArgs; |
14 | | - |
| 13 | + PHPUnit_Framework_Assert::assertTrue( true, $desc ); |
15 | 14 | if( $additionalMWCLIArgs['verbose'] ) parent::showSuccess( $desc ); |
16 | 15 | return true; |
17 | 16 | } |
18 | 17 | |
19 | 18 | public function showFailure( $desc, $expected, $got ) { |
20 | 19 | global $additionalMWCLIArgs; |
21 | | - |
| 20 | + PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc ); |
22 | 21 | if( $additionalMWCLIArgs['verbose'] ) parent::showFailure( $desc, $expected, $got ); |
23 | 22 | return false; |
24 | 23 | } |
Index: trunk/phase3/tests/phpunit/includes/parser/MediaWikiParserTest.php |
— | — | @@ -3,62 +3,72 @@ |
4 | 4 | require_once( dirname( __FILE__ ) . '/ParserHelpers.php' ); |
5 | 5 | require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' ); |
6 | 6 | |
7 | | -/** |
8 | | - * @group Parser |
9 | | - * @group Destructive |
10 | | - * @group Database |
11 | | - */ |
12 | 7 | class MediaWikiParserTest extends MediaWikiTestCase { |
13 | 8 | public $count; // Number of tests in the suite. |
| 9 | + public $backend; // ParserTestSuiteBackend instance |
14 | 10 | 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'); |
20 | 23 | |
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++; |
30 | 31 | } |
| 32 | + |
| 33 | + return $tester->suite; |
31 | 34 | } |
32 | 35 | |
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 ); |
58 | 62 | } |
59 | | - |
60 | 63 | } |
61 | | - |
| 64 | + $this->articles = array(); |
62 | 65 | } |
63 | 66 | |
| 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 | + } |
64 | 74 | } |
65 | 75 | |