3 class ParserMethodsTest
extends MediaWikiLangTestCase
{
5 public static function providePreSaveTransform() {
7 array( 'hello this is ~~~',
8 "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
10 array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
11 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
17 * @dataProvider providePreSaveTransform
19 public function testPreSaveTransform( $text, $expected ) {
22 $title = Title
::newFromText( str_replace( '::', '__', __METHOD__
) );
24 $user->setName( "127.0.0.1" );
25 $popts = ParserOptions
::newFromUser( $user );
26 $text = $wgParser->preSaveTransform( $text, $title, $user, $popts );
28 $this->assertEquals( $expected, $text );
31 public function testCallParserFunction() {
34 // Normal parses test passing PPNodes. Test passing an array.
35 $title = Title
::newFromText( str_replace( '::', '__', __METHOD__
) );
36 $wgParser->startExternalParse( $title, new ParserOptions(), Parser
::OT_HTML
);
37 $frame = $wgParser->getPreprocessor()->newFrame();
38 $ret = $wgParser->callParserFunction( $frame, '#tag',
39 array( 'pre', 'foo', 'style' => 'margin-left: 1.6em' )
41 $ret['text'] = $wgParser->mStripState
->unstripBoth( $ret['text'] );
42 $this->assertSame( array(
44 'text' => '<pre style="margin-left: 1.6em">foo</pre>',
45 ), $ret, 'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
47 // TODO: Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText()