Fix fatal error when running newParserTest
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 29 Nov 2011 14:23:24 +0000 (14:23 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 29 Nov 2011 14:23:24 +0000 (14:23 +0000)
The delayed parser test feature was expecting a ParserTest object which is
almost never the case when using the NewParserTest for PHPUnit. The class
name is forged after the file name! They at least all extends NewParserTest

no polymorphism? no multiple hinting. Be creative the PHP way by writing
your own code :-(

tests/testHelpers.inc

index 1cd611f..7618986 100644 (file)
@@ -543,7 +543,12 @@ class DelayedParserTest {
         * Called whenever we actually want to run the hook.
         * Should be the case if we found the parserTest is not disabled 
         */
-       public function unleash( ParserTest &$parserTest ) {
+       public function unleash( &$parserTest ) {
+               if( !($parserTest instanceof ParserTest || $parserTest instanceof NewParserTest
+               ) ) {
+                       throw new MWException( __METHOD__ . " must be passed an instance of ParserTest or NewParserTest classes\n" );
+               }
+
                # Trigger delayed hooks. Any failure will make us abort
                foreach( $this->hooks as $hook ) {
                        $ret = $parserTest->requireHook( $hook );