35 parent::setUpBeforeClass();
40 Language::getLocalisationCache()->recache(
'en' );
46 Language::getLocalisationCache()->recache(
'en' );
48 parent::tearDownAfterClass();
55 'wgLogTypes' => [
'phpunit' ],
56 'wgLogActionsHandlers' => [
'phpunit/test' =>
'LogFormatter',
57 'phpunit/param' =>
'LogFormatter' ],
58 'wgUser' => User::newFromName(
'Testuser' ),
61 $this->user = User::newFromName(
'Testuser' );
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:user:key',
'foo', [
'key' =>
'Foo' ] ],
312 [
'4:user-link:key',
'foo', [
'key' =>
'Foo' ] ],
359 $sep = $this->context->msg(
'colon-separator' )->text();
363 $this->context->msg(
'blocklogentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
364 . $sep . $this->user_comment,
367 '5::duration' =>
'duration',
368 '6::flags' =>
'flags',
372 # block/block - legacy
374 $this->context->msg(
'blocklogentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
375 . $sep . $this->user_comment,
387 $this->context->msg(
'unblocklogentry',
'SomeTitle' )->plain() . $sep . $this->user_comment,
394 $this->context->msg(
'reblock-logentry',
'SomeTitle',
'duration',
'(flags)' )->plain()
395 . $sep . $this->user_comment,
398 '5::duration' =>
'duration',
399 '6::flags' =>
'flags',
410 $sep = $this->context->msg(
'colon-separator' )->text();
414 $this->context->msg(
'deletedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
422 $this->context->msg(
'undeletedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
436 'newusers',
'newusers',
441 'newusers',
'create',
445 'created new account SomeTitle',
446 'newusers',
'create2',
450 'Account created automatically',
451 'newusers',
'autocreate',
462 '4::target' => $this->target->getPrefixedText(),
465 $sep = $this->context->msg(
'colon-separator' )->text();
469 $this->context->msg(
'1movedto2',
'SomeTitle',
'TestTarget' )
470 ->plain() . $sep . $this->user_comment,
478 $this->context->msg(
'1movedto2_redir',
'SomeTitle',
'TestTarget' )
479 ->plain() . $sep . $this->user_comment,
480 'move',
'move_redir',
493 $this->context->msg(
'patrol-log-line',
'revision 777',
'[[SomeTitle]]',
'' )->plain(),
497 '5::previd' =>
'666',
509 '4::description' =>
'[edit=sysop] (indefinite) [move=sysop] (indefinite)'
511 $sep = $this->context->msg(
'colon-separator' )->text();
515 $this->context->msg(
'protectedarticle',
'SomeTitle ' . $protectParams[
'4::description'] )
516 ->plain() . $sep . $this->user_comment,
517 'protect',
'protect',
524 $this->context->msg(
'unprotectedarticle',
'SomeTitle' )->plain() . $sep . $this->user_comment,
525 'protect',
'unprotect',
533 'modifiedarticleprotection',
534 'SomeTitle ' . $protectParams[
'4::description']
535 )->plain() . $sep . $this->user_comment,
543 $this->context->msg(
'movedarticleprotection',
'SomeTitle',
'OldTitle' )
544 ->plain() . $sep . $this->user_comment,
545 'protect',
'move_prot',
547 '4::oldtitle' =>
'OldTitle'
558 $sep = $this->context->msg(
'colon-separator' )->text();
562 $this->context->msg(
'uploadedimage',
'SomeTitle' )->plain() . $sep . $this->user_comment,
570 $this->context->msg(
'overwroteimage',
'SomeTitle' )->plain() . $sep . $this->user_comment,
571 'upload',
'overwrite',
582 $sep = $this->context->msg(
'colon-separator' )->text();
586 $this->context->msg(
'pagemerge-logentry',
'SomeTitle',
'Dest',
'timestamp' )->plain()
587 . $sep . $this->user_comment,
591 '5::mergepoint' =>
'timestamp',
602 $sep = $this->context->msg(
'colon-separator' )->text();
605 $msg = $this->context->msg(
'import-logentry-upload',
'SomeTitle' )->plain() .
616 $msg = $this->context->msg(
'import-logentry-interwiki',
'SomeTitle' )->plain() .
621 'import',
'interwiki',
636 $comment =
null, $msg =
'', $legacy =
false
639 $logEntry->setPerformer( $this->user );
640 $logEntry->setTarget( $this->title );
641 if ( $comment !==
null ) {
642 $logEntry->setComment( $comment );
644 $logEntry->setParameters(
$params );
645 $logEntry->setLegacy( $legacy );
648 $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()
Static methods.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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']