Last modified: 2012-03-08 19:06:18 UTC
For the sake of unit testing of extensions code, please provide an *easy* way to invoke the Parser from within a PHPUnit test. For example: /* * returns a ready-to-use Parser */ class ParserMock { var $parser; function __constructor() { $conf = new Array( ... ); $parser = new Parser( $conf ); ... } function setHook( ... ) { ... $parser->setHook( ... ); } function parse( $text ) { $title = new Title( 'test' ); $opt = new ParserOptions( ... ); returns $parser->parse( $text, $title, $opt ); } } class MyFooTagTest extends PHPUnit_Framework_TestCase { var $parserMock; function setUp() { $parserMock = new ParserMock; $myFooTag = new MyFooTag $parserMock->setHook( 'foo', array( & $myFooTag, 'foo' ) ); } function testFoo() { $out = $parserMock->parse( '<foo f="F">Bar</foo>' ); ... } }
That's basically how it is already, except you can use the actual Parser class instead of "ParserMock". Have you encountered some problem with this approach?
resetting to wikibugs-l@lists.wikimedia.org assignee.
It works this way already. Unless there was something specific requested here, it's WORKSFORME.