35 parent::setUpBeforeClass();
40 Language::getLocalisationCache()->recache(
'en' );
46 Language::getLocalisationCache()->recache(
'en' );
48 parent::tearDownAfterClass();
55 'wgLogTypes' => [
'phpunit' ],
56 'wgLogActionsHandlers' => [
'phpunit/test' => LogFormatter::class,
57 'phpunit/param' => LogFormatter::class ],
62 $this->
title = Title::newFromText(
'SomeTitle' );
63 $this->target = Title::newFromText(
'TestTarget' );
66 $this->context->setUser( $this->user );
67 $this->context->setTitle( $this->
title );
68 $this->context->setLanguage( RequestContext::getMain()->getLanguage() );
70 $this->user_comment =
'<User comment about action>';
75 $logEntry->setPerformer( $this->user );
76 $logEntry->setTarget( $this->
title );
77 $logEntry->setComment(
'A very good reason' );
79 $logEntry->setParameters(
$params );
90 $formatter->setContext( $this->context );
92 $formatter->setShowUserToolLinks(
false );
93 $paramsWithoutTools = $formatter->getMessageParametersForTesting();
96 $formatter2->setContext( $this->context );
97 $formatter2->setShowUserToolLinks(
true );
98 $paramsWithTools = $formatter2->getMessageParametersForTesting();
101 $this->user->getId(),
102 $this->user->getName()
106 $this->user->getId(),
107 $this->user->getName(),
108 $this->user->getEditCount(),
116 $this->
assertEquals( $paramsWithoutTools[1], $paramsWithTools[1] );
117 $this->
assertEquals( $paramsWithoutTools[2], $paramsWithTools[2] );
119 $this->
assertEquals( $userLink, $paramsWithoutTools[0][
'raw'] );
120 $this->
assertEquals( $userLink . $userTools, $paramsWithTools[0][
'raw'] );
122 $this->
assertEquals( $this->user->getName(), $paramsWithoutTools[1] );
124 $this->
assertEquals( $titleLink, $paramsWithoutTools[2][
'raw'] );
137 $formatter->setContext( $this->context );
139 $logParam = $formatter->getActionText();
149 $params = [
'4:msg:msg' =>
'log-description-phpunit' ];
150 $expected =
wfMessage(
'log-description-phpunit' )->text();
154 $formatter->setContext( $this->context );
156 $logParam = $formatter->getActionText();
166 $params = [
'4:msg-content:msgContent' =>
'log-description-phpunit' ];
167 $expected =
wfMessage(
'log-description-phpunit' )->inContentLanguage()->text();
171 $formatter->setContext( $this->context );
173 $logParam = $formatter->getActionText();
185 $params = [
'4:number:number' => 123456789 ];
186 $expected =
$wgLang->formatNum( 123456789 );
190 $formatter->setContext( $this->context );
192 $logParam = $formatter->getActionText();
202 $params = [
'4:user-link:userLink' => $this->user->getName() ];
204 $this->user->getId(),
205 $this->user->getName()
210 $formatter->setContext( $this->context );
212 $logParam = $formatter->getActionText();
222 $params = [
'4:title-link:titleLink' => $this->
title->getText() ];
227 $formatter->setContext( $this->context );
229 $logParam = $formatter->getActionText();
239 $params = [
'4:plain:plain' =>
'Some plain text' ];
240 $expected =
'Some plain text';
244 $formatter->setContext( $this->context );
246 $logParam = $formatter->getActionText();
258 $formatter->setContext( $this->context );
262 $this->
assertEquals( $comment, $formatter->getComment() );
273 $formatter->setContext( $this->context );
278 $this->
assertEquals( $expected, $formatter->formatParametersForApi() );
283 [ 0,
'value', [
'value' ] ],
284 [
'named',
'value', [
'named' =>
'value' ] ],
285 [
'::key',
'value', [
'key' =>
'value' ] ],
286 [
'4::key',
'value', [
'key' =>
'value' ] ],
287 [
'4:raw:key',
'value', [
'key' =>
'value' ] ],
288 [
'4:plain:key',
'value', [
'key' =>
'value' ] ],
289 [
'4:bool:key',
'1', [
'key' =>
true ] ],
290 [
'4:bool:key',
'0', [
'key' =>
false ] ],
291 [
'4:number:key',
'123', [
'key' => 123 ] ],
292 [
'4:number:key',
'123.5', [
'key' => 123.5 ] ],
296 [
'4:timestamp:key',
'20150102030405', [
'key' =>
'2015-01-02T03:04:05Z' ] ],
297 [
'4:msg:key',
'parentheses', [
298 'key_key' =>
'parentheses',
299 'key_text' =>
wfMessage(
'parentheses' )->text(),
301 [
'4:msg-content:key',
'parentheses', [
302 'key_key' =>
'parentheses',
303 'key_text' =>
wfMessage(
'parentheses' )->inContentLanguage()->text(),
305 [
'4:title:key',
'project:foo', [
307 'key_title' => Title::newFromText(
'project:foo' )->getFullText(),
309 [
'4:title-link:key',
'project:foo', [
311 'key_title' => Title::newFromText(
'project:foo' )->getFullText(),
313 [
'4:title-link:key',
'<invalid>', [
315 'key_title' => SpecialPage::getTitleFor(
'Badtitle',
'<invalid>' )->getFullText(),
317 [
'4:user:key',
'foo', [
'key' =>
'Foo' ] ],
318 [
'4:user-link:key',
'foo', [
'key' =>
'Foo' ] ],
365 $sep = $this->context->msg(
'colon-separator' )->text();
369 $this->context->msg(
'blocklogentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
370 . $sep . $this->user_comment,
373 '5::duration' =>
'duration',
374 '6::flags' =>
'flags',
378 # block/block - legacy
380 $this->context->msg(
'blocklogentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
381 . $sep . $this->user_comment,
393 $this->context->msg(
'unblocklogentry',
'SomeTitle' )->plain() . $sep . $this->user_comment,
400 $this->context->msg(
'reblock-logentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
401 . $sep . $this->user_comment,
404 '5::duration' =>
'duration',
405 '6::flags' =>
'flags',
416 $sep = $this->context->msg(
'colon-separator' )->text();
420 $this->context->msg(
'deletedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
428 $this->context->msg(
'undeletedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
442 'newusers',
'newusers',
447 'newusers',
'create',
451 'created new account SomeTitle',
452 'newusers',
'create2',
456 'Account created automatically',
457 'newusers',
'autocreate',
468 '4::target' => $this->target->getPrefixedText(),
471 $sep = $this->context->msg(
'colon-separator' )->text();
475 $this->context->msg(
'1movedto2',
'SomeTitle',
'TestTarget' )
476 ->plain() . $sep . $this->user_comment,
484 $this->context->msg(
'1movedto2_redir',
'SomeTitle',
'TestTarget' )
485 ->plain() . $sep . $this->user_comment,
486 'move',
'move_redir',
499 $this->context->msg(
'patrol-log-line',
'revision 777',
'[[SomeTitle]]',
'' )->plain(),
503 '5::previd' =>
'666',
515 '4::description' =>
'[edit=sysop] (indefinite) [move=sysop] (indefinite)'
517 $sep = $this->context->msg(
'colon-separator' )->text();
521 $this->context->msg(
'protectedarticle',
'SomeTitle ' . $protectParams[
'4::description'] )
522 ->plain() . $sep . $this->user_comment,
523 'protect',
'protect',
530 $this->context->msg(
'unprotectedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
531 'protect',
'unprotect',
539 'modifiedarticleprotection',
540 'SomeTitle ' . $protectParams[
'4::description']
541 )->plain() . $sep . $this->user_comment,
549 $this->context->msg(
'movedarticleprotection',
'SomeTitle',
'OldTitle' )
550 ->plain() . $sep . $this->user_comment,
551 'protect',
'move_prot',
553 '4::oldtitle' =>
'OldTitle'
564 $sep = $this->context->msg(
'colon-separator' )->text();
568 $this->context->msg(
'uploadedimage',
'SomeTitle' )->plain() . $sep . $this->user_comment,
576 $this->context->msg(
'overwroteimage',
'SomeTitle' )->plain() . $sep . $this->user_comment,
577 'upload',
'overwrite',
588 $sep = $this->context->msg(
'colon-separator' )->text();
592 $this->context->msg(
'pagemerge-logentry',
'SomeTitle',
'Dest',
'timestamp' )->plain()
593 . $sep . $this->user_comment,
597 '5::mergepoint' =>
'timestamp',
608 $sep = $this->context->msg(
'colon-separator' )->text();
611 $msg = $this->context->msg(
'import-logentry-upload',
'SomeTitle' )->plain() .
622 $msg = $this->context->msg(
'import-logentry-interwiki',
'SomeTitle' )->plain() .
627 'import',
'interwiki',
642 $comment =
null, $msg =
'', $legacy =
false
645 $logEntry->setPerformer( $this->user );
646 $logEntry->setTarget( $this->
title );
647 if ( $comment !==
null ) {
648 $logEntry->setComment( $comment );
650 $logEntry->setParameters(
$params );
651 $logEntry->setLegacy( $legacy );
654 $formatter->setContext( $this->context );
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
const META_TYPE
Key for the 'type' metadata item.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
static commentBlock( $comment, $title=null, $local=false, $wikiId=null, $useParentheses=true)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
static userToolLinksRedContribs( $userId, $userText, $edits=null, $useParentheses=true)
Alias for userToolLinks( $userId, $userText, true );.
Class for creating new log entries and inserting them into the database.
Group all the pieces relevant to the context of a request into one instance.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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 true
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
processing should stop and the error should be shown to the user * false
$wgExtensionMessagesFiles['ExtensionNameMagic']