16 [
'hello this is ~~~',
17 "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
19 [
'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
20 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
33 $user->setName(
"127.0.0.1" );
37 $this->assertEquals( $expected, $text );
50 "<p class='foo'>Text.</p>",
51 "<p class='foo'>Text.</p>",
58 "<p>Text.</p><p>More text.</p>",
59 "<p>Text.</p><p>More text.</p>",
72 $this->assertEquals( $expected, Parser::stripOuterParagraph( $text ) );
84 $wgParser->setHook(
'recursivecallparser', [ $this,
'helperParserFunc' ] );
85 $wgParser->parse(
'<recursivecallparser>baz</recursivecallparser>',
$title, $po );
101 $frame =
$wgParser->getPreprocessor()->newFrame();
103 [
'pre',
'foo',
'style' =>
'margin-left: 1.6em' ]
108 'text' =>
'<pre style="margin-left: 1.6em">foo</pre>',
109 ],
$ret,
'callParserFunction works for {{#tag:pre|foo|style=margin-left: 1.6em}}' );
128 'fromtitle' =>
$title->getPrefixedDBkey(),
138 'fromtitle' =>
false,
139 'byteoffset' =>
null,
148 'fromtitle' =>
$title->getPrefixedDBkey(),
152 ],
$out->getSections(),
'getSections() with proper value when <h2> is used' );
159 $this->assertEquals( $expected, Parser::normalizeLinkUrl( $url ), $explanation );
165 'Escaping of unsafe characters',
166 'http://example.org/foo bar?param[]="value"¶m[]=valüe',
167 'http://example.org/foo%20bar?param%5B%5D=%22value%22¶m%5B%5D=val%C3%BCe',
170 'Case normalization of percent-encoded characters',
171 'http://example.org/%ab%cD%Ef%FF',
172 'http://example.org/%AB%CD%EF%FF',
175 'Unescaping of safe characters',
176 'http://example.org/%3C%66%6f%6F%3E?%3C%66%6f%6F%3E#%3C%66%6f%6F%3E',
177 'http://example.org/%3Cfoo%3E?%3Cfoo%3E#%3Cfoo%3E',
180 'Context-sensitive replacement of sometimes-safe characters',
181 'http://example.org/%23%2F%3F%26%3D%2B%3B?%23%2F%3F%26%3D%2B%3B#%23%2F%3F%26%3D%2B%3B',
182 'http://example.org/%23%2F%3F&=+;?%23/?%26%3D%2B%3B#%23/?&=+;',
192 $text =
$wgParser->getOutput()->getText();
194 $this->assertContains(
'Hello World', $text );
195 $this->assertContains(
'<div', $text );
196 $this->assertContains(
'class="mw-parser-output"', $text );
205 $title->method(
'getPrefixedDBkey' )->willReturn(
$name );
206 $title->method(
'getPrefixedText' )->willReturn(
$name );
209 $title->method(
'getNamespace' )->willReturn( 0 );
219 ->disableOriginalConstructor()
222 $frank->method(
'getName' )->willReturn(
'Frank' );
224 $text =
'* user:{{REVISIONUSER}};id:{{REVISIONID}};time:{{REVISIONTIMESTAMP}};';
227 yield
'current' => [ $text, $po, 0,
'user:CurrentAuthor;id:200;time:20160606000000;' ];
228 yield
'current with ID' => [ $text, $po, 200,
'user:CurrentAuthor;id:200;time:20160606000000;' ];
230 $text =
'* user:{{REVISIONUSER}};id:{{REVISIONID}};time:{{REVISIONTIMESTAMP}};';
233 yield
'old' => [ $text, $po, 100,
'user:OldAuthor;id:100;time:20140404000000;' ];
236 $oldRevision->setId( 100 );
238 $oldRevision->setTimestamp(
'20141111111111' );
239 $oldRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'FAUX' ) );
242 $po->setCurrentRevisionCallback(
function ()
use ( $oldRevision ) {
243 return new Revision( $oldRevision );
246 yield
'old with override' => [ $text, $po, 100,
'user:FauxAuthor;id:100;time:20141111111111;' ];
248 $text =
'* user:{{REVISIONUSER}};user-subst:{{subst:REVISIONUSER}};';
251 $po->setIsPreview(
true );
253 yield
'preview without override, using context' => [
261 $text =
'* user:{{REVISIONUSER}};time:{{REVISIONTIMESTAMP}};'
262 .
'user-subst:{{subst:REVISIONUSER}};time-subst:{{subst:REVISIONTIMESTAMP}};';
266 $newRevision->setTimestamp(
'20180808000000' );
267 $newRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'NEW' ) );
270 $po->setIsPreview(
true );
271 $po->setCurrentRevisionCallback(
function ()
use ( $newRevision ) {
272 return new Revision( $newRevision );
279 'user:NewAuthor;time:20180808000000;',
280 'user-subst:NewAuthor;time-subst:20180808000000;',
284 $po->setCurrentRevisionCallback(
function ()
use ( $newRevision ) {
285 return new Revision( $newRevision );
288 yield
'pre-save' => [
292 'user:NewAuthor;time:20180808000000;',
293 'user-subst:NewAuthor;time-subst:20180808000000;',
296 $text =
"(ONE)<includeonly>(TWO)</includeonly>"
297 .
"<noinclude>#{{:ParserRevisionAccessTest}}#</noinclude>";
301 $newRevision->setTimestamp(
'20180808000000' );
302 $newRevision->setContent( SlotRecord::MAIN,
new WikitextContent( $text ) );
305 $po->setIsPreview(
true );
306 $po->setCurrentRevisionCallback(
function ()
use ( $newRevision ) {
307 return new Revision( $newRevision );
310 yield
'preview with self-transclude' => [ $text, $po,
null,
'(ONE)#(ONE)(TWO)#' ];
321 $expectedInPst =
null
330 $oldRevision->setId( 100 );
332 $oldRevision->setTimestamp(
'20140404000000' );
333 $oldRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'OLD' ) );
336 $currentRevision->setId( 200 );
338 $currentRevision->setTimestamp(
'20160606000000' );
339 $currentRevision->setContent( SlotRecord::MAIN,
new WikitextContent(
'CURRENT' ) );
342 ->disableOriginalConstructor()
346 ->method(
'getKnownCurrentRevision' )
348 [
$title, 100, $oldRevision ],
349 [
$title, 200, $currentRevision ],
350 [
$title, 0, $currentRevision ],
354 ->method(
'getRevisionById' )
356 [ 100, 0, $oldRevision ],
357 [ 200, 0, $currentRevision ],
360 $this->
setService(
'RevisionStore', $revisionStore );
365 $this->assertContains( $expectedInHtml,
$html,
'In HTML' );
367 if ( $expectedInPst !==
null ) {
369 $this->assertContains( $expectedInPst, $pst,
'After Pre-Safe Transform' );