Index: trunk/phase3/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php |
— | — | @@ -20,8 +20,7 @@ |
21 | 21 | |
22 | 22 | $tester = new self; |
23 | 23 | |
24 | | - $iter = new TestFileIterator( "$IP/maintenance/tests/parser/parserTests.txt" ); |
25 | | - $iter->setParser( $tester ); |
| 24 | + $iter = new TestFileIterator( "$IP/maintenance/tests/parser/parserTests.txt", $tester ); |
26 | 25 | $tester->count = 0; |
27 | 26 | |
28 | 27 | foreach ( $iter as $test ) { |
— | — | @@ -66,5 +65,9 @@ |
67 | 66 | public function addArticle( $name, $text, $line ) { |
68 | 67 | $this->articles[$name] = $text; |
69 | 68 | } |
| 69 | + |
| 70 | + public function showRunFile( $path ) { |
| 71 | + /* Nothing shown when run from phpunit */ |
| 72 | + } |
70 | 73 | } |
71 | 74 | |
Index: trunk/phase3/maintenance/tests/testHelpers.inc |
— | — | @@ -453,13 +453,13 @@ |
454 | 454 | class TestFileIterator implements Iterator { |
455 | 455 | private $file; |
456 | 456 | private $fh; |
457 | | - private $parser; |
| 457 | + private $parserTest; /* An instance of ParserTest (parserTests.php) or MediaWikiParserTest (phpunit) */ |
458 | 458 | private $index = 0; |
459 | 459 | private $test; |
460 | 460 | private $lineNum; |
461 | 461 | private $eof; |
462 | 462 | |
463 | | - function __construct( $file, $parser = null ) { |
| 463 | + function __construct( $file, $parserTest = null ) { |
464 | 464 | global $IP; |
465 | 465 | |
466 | 466 | $this->file = $file; |
— | — | @@ -469,19 +469,15 @@ |
470 | 470 | wfDie( "Couldn't open file '$file'\n" ); |
471 | 471 | } |
472 | 472 | |
473 | | - $this->parser = $parser; |
| 473 | + $this->parserTest = $parserTest; |
474 | 474 | |
475 | | - if ( $this->parser ) { |
476 | | - $this->parser->showRunFile( wfRelativePath( $this->file, $IP ) ); |
| 475 | + if ( $this->parserTest ) { |
| 476 | + $this->parserTest->showRunFile( wfRelativePath( $this->file, $IP ) ); |
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->lineNum = $this->index = 0; |
480 | 480 | } |
481 | 481 | |
482 | | - function setParser( MediaWikiParserTest $parser ) { |
483 | | - $this->parser = $parser; |
484 | | - } |
485 | | - |
486 | 482 | function rewind() { |
487 | 483 | if ( fseek( $this->fh, 0 ) ) { |
488 | 484 | wfDie( "Couldn't fseek to the start of '$this->file'\n" ); |
— | — | @@ -536,9 +532,9 @@ |
537 | 533 | wfDie( "'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" ); |
538 | 534 | } |
539 | 535 | |
540 | | - if ( $this->parser ) { |
541 | | - $this->parser->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum ); |
542 | | - } else { |
| 536 | + if ( $this->parserTest ) { |
| 537 | + $this->parserTest->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum ); |
| 538 | + } else {wfDie("JAJA"); |
543 | 539 | ParserTest::addArticle( $data['article'], $data['text'], $this->lineNum ); |
544 | 540 | } |
545 | 541 | $data = array(); |
— | — | @@ -556,7 +552,7 @@ |
557 | 553 | $line = trim( $line ); |
558 | 554 | |
559 | 555 | if ( $line ) { |
560 | | - if ( $this->parser && !$this->parser->requireHook( $line ) ) { |
| 556 | + if ( $this->parserTest && !$this->parserTest->requireHook( $line ) ) { |
561 | 557 | return false; |
562 | 558 | } |
563 | 559 | } |
— | — | @@ -577,7 +573,7 @@ |
578 | 574 | $line = trim( $line ); |
579 | 575 | |
580 | 576 | if ( $line ) { |
581 | | - if ( $this->parser && !$this->parser->requireFunctionHook( $line ) ) { |
| 577 | + if ( $this->parserTest && !$this->parserTest->requireFunctionHook( $line ) ) { |
582 | 578 | return false; |
583 | 579 | } |
584 | 580 | } |
— | — | @@ -609,9 +605,9 @@ |
610 | 606 | if ( !isset( $data['config'] ) ) |
611 | 607 | $data['config'] = ''; |
612 | 608 | |
613 | | - if ( $this->parser |
614 | | - && ( ( preg_match( '/\\bdisabled\\b/i', $data['options'] ) && !$this->parser->runDisabled ) |
615 | | - || !preg_match( "/" . $this->parser->regex . "/i", $data['test'] ) ) ) { |
| 609 | + if ( $this->parserTest |
| 610 | + && ( ( preg_match( '/\\bdisabled\\b/i', $data['options'] ) && !$this->parserTest->runDisabled ) |
| 611 | + || !preg_match( "/" . $this->parserTest->regex . "/i", $data['test'] ) ) ) { |
616 | 612 | # disabled test |
617 | 613 | $data = array(); |
618 | 614 | $section = null; |
— | — | @@ -621,7 +617,7 @@ |
622 | 618 | |
623 | 619 | global $wgUseTeX; |
624 | 620 | |
625 | | - if ( $this->parser && |
| 621 | + if ( $this->parserTest && |
626 | 622 | preg_match( '/\\bmath\\b/i', $data['options'] ) && !$wgUseTeX ) { |
627 | 623 | # don't run math tests if $wgUseTeX is set to false in LocalSettings |
628 | 624 | $data = array(); |
— | — | @@ -630,7 +626,7 @@ |
631 | 627 | continue; |
632 | 628 | } |
633 | 629 | |
634 | | - if ( $this->parser ) { |
| 630 | + if ( $this->parserTest ) { |
635 | 631 | $this->test = array( |
636 | 632 | 'test' => ParserTest::chomp( $data['test'] ), |
637 | 633 | 'input' => ParserTest::chomp( $data['input'] ), |