summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/logging
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-04-25 06:26:49 +0200
committerPierre Schmitz <pierre@archlinux.de>2014-04-25 06:26:49 +0200
commit2e44b49a2db3026050b136de9b00f749dd3ff939 (patch)
treeef048f4db79a93c25cfc86319264aa7ae2a4ae0b /tests/phpunit/includes/logging
parent9441dde8bfb95277df073717ed7817dced40f948 (diff)
Update to MediaWiki 1.22.6
Diffstat (limited to 'tests/phpunit/includes/logging')
-rw-r--r--tests/phpunit/includes/logging/LogFormatterTest.php207
-rw-r--r--tests/phpunit/includes/logging/LogTests.i18n.php15
2 files changed, 0 insertions, 222 deletions
diff --git a/tests/phpunit/includes/logging/LogFormatterTest.php b/tests/phpunit/includes/logging/LogFormatterTest.php
deleted file mode 100644
index e8ccf433..00000000
--- a/tests/phpunit/includes/logging/LogFormatterTest.php
+++ /dev/null
@@ -1,207 +0,0 @@
-<?php
-/**
- * @group Database
- */
-class LogFormatterTest extends MediaWikiLangTestCase {
-
- /**
- * @var User
- */
- protected $user;
-
- /**
- * @var Title
- */
- protected $title;
-
- /**
- * @var RequestContext
- */
- protected $context;
-
- protected function setUp() {
- parent::setUp();
-
- global $wgLang;
-
- $this->setMwGlobals( array(
- 'wgLogTypes' => array( 'phpunit' ),
- 'wgLogActionsHandlers' => array( 'phpunit/test' => 'LogFormatter',
- 'phpunit/param' => 'LogFormatter' ),
- 'wgUser' => User::newFromName( 'Testuser' ),
- 'wgExtensionMessagesFiles' => array( 'LogTests' => __DIR__ . '/LogTests.i18n.php' ),
- ) );
-
- $wgLang->getLocalisationCache()->recache( $wgLang->getCode() );
-
- $this->user = User::newFromName( 'Testuser' );
- $this->title = Title::newMainPage();
-
- $this->context = new RequestContext();
- $this->context->setUser( $this->user );
- $this->context->setTitle( $this->title );
- $this->context->setLanguage( $wgLang );
- }
-
- protected function tearDown() {
- parent::tearDown();
-
- global $wgLang;
- $wgLang->getLocalisationCache()->recache( $wgLang->getCode() );
- }
-
- public function newLogEntry( $action, $params ) {
- $logEntry = new ManualLogEntry( 'phpunit', $action );
- $logEntry->setPerformer( $this->user );
- $logEntry->setTarget( $this->title );
- $logEntry->setComment( 'A very good reason' );
-
- $logEntry->setParameters( $params );
-
- return $logEntry;
- }
-
- public function testNormalLogParams() {
- $entry = $this->newLogEntry( 'test', array() );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $formatter->setShowUserToolLinks( false );
- $paramsWithoutTools = $formatter->getMessageParametersForTesting();
- unset( $formatter->parsedParameters );
-
- $formatter->setShowUserToolLinks( true );
- $paramsWithTools = $formatter->getMessageParametersForTesting();
-
- $userLink = Linker::userLink(
- $this->user->getId(),
- $this->user->getName()
- );
-
- $userTools = Linker::userToolLinksRedContribs(
- $this->user->getId(),
- $this->user->getName(),
- $this->user->getEditCount()
- );
-
- $titleLink = Linker::link( $this->title, null, array(), array() );
-
- // $paramsWithoutTools and $paramsWithTools should be only different
- // in index 0
- $this->assertEquals( $paramsWithoutTools[1], $paramsWithTools[1] );
- $this->assertEquals( $paramsWithoutTools[2], $paramsWithTools[2] );
-
- $this->assertEquals( $userLink, $paramsWithoutTools[0]['raw'] );
- $this->assertEquals( $userLink . $userTools, $paramsWithTools[0]['raw'] );
-
- $this->assertEquals( $this->user->getName(), $paramsWithoutTools[1] );
-
- $this->assertEquals( $titleLink, $paramsWithoutTools[2]['raw'] );
- }
-
- public function testLogParamsTypeRaw() {
- $params = array( '4:raw:raw' => Linker::link( $this->title, null, array(), array() ) );
- $expected = Linker::link( $this->title, null, array(), array() );
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogParamsTypeMsg() {
- $params = array( '4:msg:msg' => 'log-description-phpunit' );
- $expected = wfMessage( 'log-description-phpunit' )->text();
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogParamsTypeMsgContent() {
- $params = array( '4:msg-content:msgContent' => 'log-description-phpunit' );
- $expected = wfMessage( 'log-description-phpunit' )->inContentLanguage()->text();
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogParamsTypeNumber() {
- global $wgLang;
-
- $params = array( '4:number:number' => 123456789 );
- $expected = $wgLang->formatNum( 123456789 );
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogParamsTypeUserLink() {
- $params = array( '4:user-link:userLink' => $this->user->getName() );
- $expected = Linker::userLink(
- $this->user->getId(),
- $this->user->getName()
- );
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogParamsTypeTitleLink() {
- $params = array( '4:title-link:titleLink' => $this->title->getText() );
- $expected = Linker::link( $this->title, null, array(), array() );
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogParamsTypePlain() {
- $params = array( '4:plain:plain' => 'Some plain text' );
- $expected = 'Some plain text';
-
- $entry = $this->newLogEntry( 'param', $params );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $logParam = $formatter->getActionText();
-
- $this->assertEquals( $expected, $logParam );
- }
-
- public function testLogComment() {
- $entry = $this->newLogEntry( 'test', array() );
- $formatter = LogFormatter::newFromEntry( $entry );
- $formatter->setContext( $this->context );
-
- $comment = ltrim( Linker::commentBlock( $entry->getComment() ) );
-
- $this->assertEquals( $comment, $formatter->getComment() );
- }
-}
diff --git a/tests/phpunit/includes/logging/LogTests.i18n.php b/tests/phpunit/includes/logging/LogTests.i18n.php
deleted file mode 100644
index 78787ba1..00000000
--- a/tests/phpunit/includes/logging/LogTests.i18n.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-/**
- * Internationalisation file for log tests.
- *
- * @file
- */
-
-$messages = array();
-
-$messages['en'] = array(
- 'log-name-phpunit' => 'PHPUnit-log',
- 'log-description-phpunit' => 'Log for PHPUnit-tests',
- 'logentry-phpunit-test' => '$1 {{GENDER:$2|tests}} with page $3',
- 'logentry-phpunit-param' => '$4',
-);