40 ->disableOriginalConstructor()
42 $mock->expects( $this->
any() )
43 ->method(
'getNamespace' )
45 $mock->expects( $this->
any() )
48 $mock->expects( $this->
any() )
49 ->method(
'getPrefixedText' )
51 $mock->expects( $this->
any() )
52 ->method(
'getDBkey' )
54 $mock->expects( $this->
any() )
55 ->method(
'getArticleID' )
57 $mock->expects( $this->
any() )
58 ->method(
'getLatestRevId' )
60 $mock->expects( $this->
any() )
61 ->method(
'getContentModel' )
63 $mock->expects( $this->
any() )
64 ->method(
'getPageLanguage' )
65 ->will( $this->
returnValue( Language::factory(
'en' ) ) );
66 $mock->expects( $this->
any() )
67 ->method(
'isContentPage' )
69 $mock->expects( $this->
any() )
72 function ( Title $other ) use ( $mock ) {
73 return $mock->getArticleID() === $other->getArticleID();
76 $mock->expects( $this->
any() )
79 function ( $perm,
User $user )
use ( $mock ) {
80 return $user->isAllowed( $perm );
96 $db->method(
'selectField' )
98 function ( $table, $fields, $cond ) use ( $maxRev, $linkCount ) {
121 $lb = $this->
getMock( ILoadBalancer::class );
122 $lb->method(
'getConnection' )
125 $lb->method(
'getConnectionRef' )
128 $lb->method(
'getLazyConnectionRef' )
134 ->disableOriginalConstructor()
136 $slotRoles->method(
'getMap' )
140 $roleReg->defineRole(
'main',
function () {
149 if ( [ $table, $fields, $cond ] === [
'revision',
'MAX(rev_id)', [] ] ) {
153 $this->fail(
'Unexpected call to selectField' );
154 throw new LogicException(
'Ooops' );
163 $rev->setTimestamp(
'20180101000003' );
164 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
167 $text .=
"* page:{{PAGENAME}}\n";
168 $text .=
"* rev:{{REVISIONID}}\n";
169 $text .=
"* user:{{REVISIONUSER}}\n";
170 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
171 $text .=
"* [[Link It]]\n";
175 $options = ParserOptions::newCanonical(
'canonical' );
178 $this->
assertFalse( $rr->isContentDeleted(),
'isContentDeleted' );
183 $html = $rr->getRevisionParserOutput()->getText();
190 $this->
assertSame(
$html, $rr->getSlotParserOutput( SlotRecord::MAIN )->getText() );
200 $rev->setTimestamp(
'20180101000003' );
201 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
204 $text .=
"* page:{{PAGENAME}}\n";
205 $text .=
"* rev:{{REVISIONID}}\n";
206 $text .=
"* user:{{REVISIONUSER}}\n";
207 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
211 $options = ParserOptions::newCanonical(
'canonical' );
214 $this->
assertFalse( $rr->isContentDeleted(),
'isContentDeleted' );
219 $html = $rr->getRevisionParserOutput()->getText();
226 $this->
assertSame(
$html, $rr->getSlotParserOutput( SlotRecord::MAIN )->getText() );
236 $rev->setTimestamp(
'20180101000003' );
237 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
240 $text .=
"* page:{{PAGENAME}}\n";
241 $text .=
"* rev:{{REVISIONID}}\n";
242 $text .=
"* user:{{REVISIONUSER}}\n";
243 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
247 $options = ParserOptions::newCanonical(
'canonical' );
248 $rr = $renderer->getRenderedRevision(
$rev,
$options,
null, [
'use-master' =>
true ] );
250 $this->
assertFalse( $rr->isContentDeleted(),
'isContentDeleted' );
252 $html = $rr->getRevisionParserOutput()->getText();
256 $this->
assertSame(
$html, $rr->getSlotParserOutput( SlotRecord::MAIN )->getText() );
266 $rev->setTimestamp(
'20180101000003' );
267 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
269 $text =
"uncached text";
274 $options = ParserOptions::newCanonical(
'canonical' );
275 $rr = $renderer->getRenderedRevision(
279 [
'known-revision-output' =>
$output ]
283 $this->
assertSame(
'cached text', $rr->getRevisionParserOutput()->getText() );
284 $this->
assertSame(
'cached text', $rr->getSlotParserOutput( SlotRecord::MAIN )->getText() );
294 $rev->setTimestamp(
'20180101000003' );
295 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
298 $text .=
"* page:{{PAGENAME}}\n";
299 $text .=
"* rev:{{REVISIONID}}\n";
300 $text .=
"* user:{{REVISIONUSER}}\n";
301 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
305 $options = ParserOptions::newCanonical(
'canonical' );
308 $this->
assertFalse( $rr->isContentDeleted(),
'isContentDeleted' );
313 $html = $rr->getRevisionParserOutput()->getText();
320 $this->
assertSame(
$html, $rr->getSlotParserOutput(
'main' )->getText() );
329 $rev->setVisibility( RevisionRecord::DELETED_TEXT );
331 $rev->setTimestamp(
'20180101000003' );
332 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
335 $text .=
"* page:{{PAGENAME}}\n";
336 $text .=
"* rev:{{REVISIONID}}\n";
337 $text .=
"* user:{{REVISIONUSER}}\n";
338 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
342 $options = ParserOptions::newCanonical(
'canonical' );
345 $this->
assertNull( $rr,
'getRenderedRevision' );
354 $rev->setVisibility( RevisionRecord::DELETED_TEXT );
356 $rev->setTimestamp(
'20180101000003' );
357 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
360 $text .=
"* page:{{PAGENAME}}\n";
361 $text .=
"* rev:{{REVISIONID}}\n";
362 $text .=
"* user:{{REVISIONUSER}}\n";
363 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
367 $options = ParserOptions::newCanonical(
'canonical' );
368 $sysop = $this->
getTestUser( [
'sysop' ] )->getUser();
369 $rr = $renderer->getRenderedRevision(
$rev,
$options, $sysop );
371 $this->
assertTrue( $rr->isContentDeleted(),
'isContentDeleted' );
376 $html = $rr->getRevisionParserOutput()->getText();
384 $this->
assertSame(
$html, $rr->getSlotParserOutput(
'main' )->getText() );
393 $rev->setVisibility( RevisionRecord::DELETED_TEXT );
395 $rev->setTimestamp(
'20180101000003' );
396 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
399 $text .=
"* page:{{PAGENAME}}\n";
400 $text .=
"* rev:{{REVISIONID}}\n";
401 $text .=
"* user:{{REVISIONUSER}}\n";
402 $text .=
"* time:{{REVISIONTIMESTAMP}}\n";
406 $options = ParserOptions::newCanonical(
'canonical' );
407 $rr = $renderer->getRenderedRevision(
411 [
'audience' => RevisionRecord::RAW ]
414 $this->
assertTrue( $rr->isContentDeleted(),
'isContentDeleted' );
419 $html = $rr->getRevisionParserOutput()->getText();
427 $this->
assertSame(
$html, $rr->getSlotParserOutput(
'main' )->getText() );
436 $rev->setTimestamp(
'20180101000003' );
437 $rev->setComment( CommentStoreComment::newUnsavedComment(
'' ) );
442 $rr = $renderer->getRenderedRevision(
$rev );
444 $combinedOutput = $rr->getRevisionParserOutput();
445 $mainOutput = $rr->getSlotParserOutput( SlotRecord::MAIN );
446 $auxOutput = $rr->getSlotParserOutput(
'aux' );
448 $combinedHtml = $combinedOutput->getText();
449 $mainHtml = $mainOutput->getText();
450 $auxHtml = $auxOutput->getText();
459 $this->
assertNotContains(
'<mw:slotheader', $combinedHtml,
'slot header placeholder' );
464 $this->
assertContains(
'class="mw-parser-output"', $combinedHtml );
468 $this->
assertNotContains(
'class="mw-parser-output"', $combinedOutput->getRawText() );
470 $combinedLinks = $combinedOutput->getLinks();
471 $mainLinks = $mainOutput->getLinks();
472 $auxLinks = $auxOutput->getLinks();
482 ->setMethods( [
'getParserOutput' ] )
483 ->setConstructorArgs( [
'Whatever' ] )
485 $mockContent->method(
'getParserOutput' )
486 ->willReturnCallback(
function (
Title $title, $revId =
null,
489 if ( !$generateHtml ) {
492 $this->fail(
'Should not be called with $generateHtml == true' );
501 $rev->setContent( SlotRecord::MAIN, $mockContent );
502 $rev->setContent(
'aux', $mockContent );
505 $rr = $renderer->getRenderedRevision(
$rev );
507 $output = $rr->getSlotParserOutput( SlotRecord::MAIN, [
'generate-html' =>
false ] );
510 $output = $rr->getRevisionParserOutput( [
'generate-html' =>
false ] );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Internationalisation code.
A SlotRoleHandler for the main slot.
Set options of the Parser.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Content object for wiki text pages.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
const CONTENT_MODEL_WIKITEXT
Base interface for content objects.