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 );
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();
94 unset( $formatter->parsedParameters );
96 $formatter->setShowUserToolLinks(
true );
97 $paramsWithTools = $formatter->getMessageParametersForTesting();
100 $this->user->getId(),
101 $this->user->getName()
105 $this->user->getId(),
106 $this->user->getName(),
107 $this->user->getEditCount()
110 $titleLink =
Linker::link( $this->title,
null, [], [] );
114 $this->assertEquals( $paramsWithoutTools[1], $paramsWithTools[1] );
115 $this->assertEquals( $paramsWithoutTools[2], $paramsWithTools[2] );
117 $this->assertEquals( $userLink, $paramsWithoutTools[0][
'raw'] );
118 $this->assertEquals( $userLink . $userTools, $paramsWithTools[0][
'raw'] );
120 $this->assertEquals( $this->user->getName(), $paramsWithoutTools[1] );
122 $this->assertEquals( $titleLink, $paramsWithoutTools[2][
'raw'] );
135 $formatter->setContext( $this->context );
137 $logParam = $formatter->getActionText();
139 $this->assertEquals( $expected, $logParam );
147 $params = [
'4:msg:msg' =>
'log-description-phpunit' ];
148 $expected =
wfMessage(
'log-description-phpunit' )->text();
152 $formatter->setContext( $this->context );
154 $logParam = $formatter->getActionText();
156 $this->assertEquals( $expected, $logParam );
164 $params = [
'4:msg-content:msgContent' =>
'log-description-phpunit' ];
165 $expected =
wfMessage(
'log-description-phpunit' )->inContentLanguage()->text();
169 $formatter->setContext( $this->context );
171 $logParam = $formatter->getActionText();
173 $this->assertEquals( $expected, $logParam );
183 $params = [
'4:number:number' => 123456789 ];
184 $expected =
$wgLang->formatNum( 123456789 );
188 $formatter->setContext( $this->context );
190 $logParam = $formatter->getActionText();
192 $this->assertEquals( $expected, $logParam );
200 $params = [
'4:user-link:userLink' => $this->user->getName() ];
202 $this->user->getId(),
203 $this->user->getName()
208 $formatter->setContext( $this->context );
210 $logParam = $formatter->getActionText();
212 $this->assertEquals( $expected, $logParam );
220 $params = [
'4:title-link:titleLink' => $this->title->getText() ];
225 $formatter->setContext( $this->context );
227 $logParam = $formatter->getActionText();
229 $this->assertEquals( $expected, $logParam );
237 $params = [
'4:plain:plain' =>
'Some plain text' ];
238 $expected =
'Some plain text';
242 $formatter->setContext( $this->context );
244 $logParam = $formatter->getActionText();
246 $this->assertEquals( $expected, $logParam );
256 $formatter->setContext( $this->context );
260 $this->assertEquals( $comment, $formatter->getComment() );
271 $formatter->setContext( $this->context );
276 $this->assertEquals( $expected, $formatter->formatParametersForApi() );
281 [ 0,
'value', [
'value' ] ],
282 [
'named',
'value', [
'named' =>
'value' ] ],
283 [
'::key',
'value', [
'key' =>
'value' ] ],
284 [
'4::key',
'value', [
'key' =>
'value' ] ],
285 [
'4:raw:key',
'value', [
'key' =>
'value' ] ],
286 [
'4:plain:key',
'value', [
'key' =>
'value' ] ],
287 [
'4:bool:key',
'1', [
'key' =>
true ] ],
288 [
'4:bool:key',
'0', [
'key' =>
false ] ],
289 [
'4:number:key',
'123', [
'key' => 123 ] ],
290 [
'4:number:key',
'123.5', [
'key' => 123.5 ] ],
294 [
'4:timestamp:key',
'20150102030405', [
'key' =>
'2015-01-02T03:04:05Z' ] ],
295 [
'4:msg:key',
'parentheses', [
296 'key_key' =>
'parentheses',
297 'key_text' =>
wfMessage(
'parentheses' )->text(),
299 [
'4:msg-content:key',
'parentheses', [
300 'key_key' =>
'parentheses',
301 'key_text' =>
wfMessage(
'parentheses' )->inContentLanguage()->text(),
303 [
'4:title:key',
'project:foo', [
305 'key_title' => Title::newFromText(
'project:foo' )->getFullText(),
307 [
'4:title-link:key',
'project:foo', [
309 'key_title' => Title::newFromText(
'project:foo' )->getFullText(),
311 [
'4:title-link:key',
'<invalid>', [
313 'key_title' => SpecialPage::getTitleFor(
'Badtitle',
'<invalid>' )->getFullText(),
315 [
'4:user:key',
'foo', [
'key' =>
'Foo' ] ],
316 [
'4:user-link:key',
'foo', [
'key' =>
'Foo' ] ],
363 $sep = $this->context->msg(
'colon-separator' )->text();
367 $this->context->msg(
'blocklogentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
368 . $sep . $this->user_comment,
371 '5::duration' =>
'duration',
372 '6::flags' =>
'flags',
376 # block/block - legacy
378 $this->context->msg(
'blocklogentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
379 . $sep . $this->user_comment,
391 $this->context->msg(
'unblocklogentry',
'SomeTitle' )->plain() . $sep . $this->user_comment,
398 $this->context->msg(
'reblock-logentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
399 . $sep . $this->user_comment,
402 '5::duration' =>
'duration',
403 '6::flags' =>
'flags',
414 $sep = $this->context->msg(
'colon-separator' )->text();
418 $this->context->msg(
'deletedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
426 $this->context->msg(
'undeletedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
440 'newusers',
'newusers',
445 'newusers',
'create',
449 'created new account SomeTitle',
450 'newusers',
'create2',
454 'Account created automatically',
455 'newusers',
'autocreate',
466 '4::target' => $this->target->getPrefixedText(),
469 $sep = $this->context->msg(
'colon-separator' )->text();
473 $this->context->msg(
'1movedto2',
'SomeTitle',
'TestTarget' )
474 ->plain() . $sep . $this->user_comment,
482 $this->context->msg(
'1movedto2_redir',
'SomeTitle',
'TestTarget' )
483 ->plain() . $sep . $this->user_comment,
484 'move',
'move_redir',
497 $this->context->msg(
'patrol-log-line',
'revision 777',
'[[SomeTitle]]',
'' )->plain(),
501 '5::previd' =>
'666',
513 '4::description' =>
'[edit=sysop] (indefinite) [move=sysop] (indefinite)'
515 $sep = $this->context->msg(
'colon-separator' )->text();
519 $this->context->msg(
'protectedarticle',
'SomeTitle ' . $protectParams[
'4::description'] )
520 ->plain() . $sep . $this->user_comment,
521 'protect',
'protect',
528 $this->context->msg(
'unprotectedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
529 'protect',
'unprotect',
537 'modifiedarticleprotection',
538 'SomeTitle ' . $protectParams[
'4::description']
539 )->plain() . $sep . $this->user_comment,
547 $this->context->msg(
'movedarticleprotection',
'SomeTitle',
'OldTitle' )
548 ->plain() . $sep . $this->user_comment,
549 'protect',
'move_prot',
551 '4::oldtitle' =>
'OldTitle'
562 $sep = $this->context->msg(
'colon-separator' )->text();
566 $this->context->msg(
'uploadedimage',
'SomeTitle' )->plain() . $sep . $this->user_comment,
574 $this->context->msg(
'overwroteimage',
'SomeTitle' )->plain() . $sep . $this->user_comment,
575 'upload',
'overwrite',
586 $sep = $this->context->msg(
'colon-separator' )->text();
590 $this->context->msg(
'pagemerge-logentry',
'SomeTitle',
'Dest',
'timestamp' )->plain()
591 . $sep . $this->user_comment,
595 '5::mergepoint' =>
'timestamp',
606 $sep = $this->context->msg(
'colon-separator' )->text();
609 $msg = $this->context->msg(
'import-logentry-upload',
'SomeTitle' )->plain() .
620 $msg = $this->context->msg(
'import-logentry-interwiki',
'SomeTitle' )->plain() .
625 'import',
'interwiki',
640 $comment =
null, $msg =
'', $legacy =
false
643 $logEntry->setPerformer( $this->user );
644 $logEntry->setTarget( $this->title );
645 if ( $comment !==
null ) {
646 $logEntry->setComment( $comment );
648 $logEntry->setParameters(
$params );
649 $logEntry->setLegacy( $legacy );
652 $formatter->setContext( $this->context );
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 userToolLinksRedContribs( $userId, $userText, $edits=null)
Alias for userToolLinks( $userId, $userText, true );.
static commentBlock( $comment, $title=null, $local=false, $wikiId=null)
Wrap a comment in standard punctuation and formatting if it's non-empty, otherwise return empty strin...
Class for creating log entries manually, to inject them into the database.
Group all the pieces relevant to the context of a request into one instance.
static getMain()
Get the RequestContext object associated with the main request.
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.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
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 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
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
processing should stop and the error should be shown to the user * false
$wgExtensionMessagesFiles['ExtensionNameMagic']