On Thu, Nov 1, 2012 at 6:11 PM, Daniel Barrett <danb(a)vistaprint.com> wrote:
I'm trying to test a parser tag extension with
phpunit and have run into a
strange problem. Whenever my extension calls $parser->recursiveTagParse(), the unit
test blows up in Parser.php, complaining that $parser->mOptions is a non-object.
The tag callback looks pretty normal:
static function render($input, $argv, $parser, $frame) {
// ...
$parser->recursiveTagParse("something");
// ...
}
and I have unit tests that call render()directly:
public function testMyTag() {
global $wgParser;
$this->assertEqual(MyTag::render("some text", array(), $wgParser,
false));
}
(I don't like using $wgParser here, and maybe that's the root of my problems?)
The tag works perfectly in the browser. Just not when unit-testing on the command
line.
The blowup occurs in Parser.php::replaceVariables, when it calls
$this->mOptions->getMaxIncludeSize().
Any advice appreciated!!
Thanks,
DanB
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
You're calling the recursiveTagParse while the parser is not in a
"parsing" state.
The easiest way to do this is to have some text "yadda
yadda<mytag>foo</mytag>" and pass it to
$wgParser->parse, and have the parser being the thing calling your
callback. (If you're going to do that
approach you can even use older style parser tests text file with
$wgParserTestFiles if you wanted
as its basically doing the same thing)
You can also work around this (I believe anyhow) by doing something
complicated with
Parser->startExternalParse first and then doing what you are doing,
but I've never really used that method and am not sure how it works.
Hope that helps,
-bawolff