From: Alexandre Emsenhuber Date: Mon, 5 Mar 2012 21:21:34 +0000 (+0000) Subject: Make RecentChangeTest work by using the same context for expected and actual results... X-Git-Tag: 1.31.0-rc.0~24384 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=1f6f0371cc8eaf9e1a707d942cd920971e395467;p=lhc%2Fweb%2Fwiklou.git Make RecentChangeTest work by using the same context for expected and actual results. They were failing on my installation because $wgLang->getCode() != $wgContLang->getCode() when the test was called. --- diff --git a/tests/phpunit/includes/RecentChangeTest.php b/tests/phpunit/includes/RecentChangeTest.php index 0db4d7783c..7865ed24b6 100644 --- a/tests/phpunit/includes/RecentChangeTest.php +++ b/tests/phpunit/includes/RecentChangeTest.php @@ -4,6 +4,7 @@ class RecentChangeTest extends MediaWikiTestCase { protected $target; protected $user; protected $user_comment; + protected $context; function __construct() { parent::__construct(); @@ -13,6 +14,7 @@ class RecentChangeTest extends MediaWikiTestCase { $this->user = User::newFromName( 'UserName' ); $this->user_comment = ''; + $this->context = RequestContext::newExtraneousContext( $this->title ); } /** @@ -54,14 +56,14 @@ class RecentChangeTest extends MediaWikiTestCase { function testIrcMsgForLogTypeBlock() { # block/block $this->assertIRCComment( - wfMessage( 'blocklogentry', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'blocklogentry', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'block', 'block', array(), $this->user_comment ); # block/unblock $this->assertIRCComment( - wfMessage( 'unblocklogentry', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'unblocklogentry', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'block', 'unblock', array(), $this->user_comment @@ -74,7 +76,7 @@ class RecentChangeTest extends MediaWikiTestCase { function testIrcMsgForLogTypeDelete() { # delete/delete $this->assertIRCComment( - wfMessage( 'deletedarticle', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'deletedarticle', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'delete', 'delete', array(), $this->user_comment @@ -82,7 +84,7 @@ class RecentChangeTest extends MediaWikiTestCase { # delete/restore $this->assertIRCComment( - wfMessage( 'undeletedarticle', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'undeletedarticle', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'delete', 'restore', array(), $this->user_comment @@ -126,7 +128,7 @@ class RecentChangeTest extends MediaWikiTestCase { # move/move $this->assertIRCComment( - wfMessage( '1movedto2', 'SomeTitle', 'TestTarget' )->plain() . ': ' . $this->user_comment, + $this->context->msg( '1movedto2', 'SomeTitle', 'TestTarget' )->plain() . ': ' . $this->user_comment, 'move', 'move', $move_params, $this->user_comment @@ -134,7 +136,7 @@ class RecentChangeTest extends MediaWikiTestCase { # move/move_redir $this->assertIRCComment( - wfMessage( '1movedto2_redir', 'SomeTitle', 'TestTarget' )->plain() . ': ' . $this->user_comment, + $this->context->msg( '1movedto2_redir', 'SomeTitle', 'TestTarget' )->plain() . ': ' . $this->user_comment, 'move', 'move_redir', $move_params, $this->user_comment @@ -147,7 +149,7 @@ class RecentChangeTest extends MediaWikiTestCase { function testIrcMsgForLogTypePatrol() { # patrol/patrol $this->assertIRCComment( - wfMessage( 'patrol-log-line', 'revision 777', '[[SomeTitle]]', '' )->plain(), + $this->context->msg( 'patrol-log-line', 'revision 777', '[[SomeTitle]]', '' )->plain(), 'patrol', 'patrol', array( '4::curid' => '777', @@ -167,7 +169,7 @@ class RecentChangeTest extends MediaWikiTestCase { # protect/protect $this->assertIRCComment( - wfMessage( 'protectedarticle', 'SomeTitle ' . $protectParams[0] )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'protectedarticle', 'SomeTitle ' . $protectParams[0] )->plain() . ': ' . $this->user_comment, 'protect', 'protect', $protectParams, $this->user_comment @@ -175,7 +177,7 @@ class RecentChangeTest extends MediaWikiTestCase { # protect/unprotect $this->assertIRCComment( - wfMessage( 'unprotectedarticle', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'unprotectedarticle', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'protect', 'unprotect', array(), $this->user_comment @@ -183,7 +185,7 @@ class RecentChangeTest extends MediaWikiTestCase { # protect/modify $this->assertIRCComment( - wfMessage( 'modifiedarticleprotection', 'SomeTitle ' . $protectParams[0] )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'modifiedarticleprotection', 'SomeTitle ' . $protectParams[0] )->plain() . ': ' . $this->user_comment, 'protect', 'modify', $protectParams, $this->user_comment @@ -196,7 +198,7 @@ class RecentChangeTest extends MediaWikiTestCase { function testIrcMsgForLogTypeUpload() { # upload/upload $this->assertIRCComment( - wfMessage( 'uploadedimage', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'uploadedimage', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'upload', 'upload', array(), $this->user_comment @@ -204,7 +206,7 @@ class RecentChangeTest extends MediaWikiTestCase { # upload/overwrite $this->assertIRCComment( - wfMessage( 'overwroteimage', 'SomeTitle' )->plain() . ': ' . $this->user_comment, + $this->context->msg( 'overwroteimage', 'SomeTitle' )->plain() . ': ' . $this->user_comment, 'upload', 'overwrite', array(), $this->user_comment @@ -217,19 +219,19 @@ class RecentChangeTest extends MediaWikiTestCase { * -- function testIrcMsgForBlankingAES() { - // wfMessage( 'autosumm-blank', .. ); + // $this->context->msg( 'autosumm-blank', .. ); } function testIrcMsgForReplaceAES() { - // wfMessage( 'autosumm-replace', .. ); + // $this->context->msg( 'autosumm-replace', .. ); } function testIrcMsgForRollbackAES() { - // wfMessage( 'revertpage', .. ); + // $this->context->msg( 'revertpage', .. ); } function testIrcMsgForUndoAES() { - // wfMessage( 'undo-summary', .. ); + // $this->context->msg( 'undo-summary', .. ); } * -- @@ -253,7 +255,7 @@ class RecentChangeTest extends MediaWikiTestCase { $logEntry->setParameters( $params ); $formatter = LogFormatter::newFromEntry( $logEntry ); - $formatter->setContext( RequestContext::newExtraneousContext( $this->title ) ); + $formatter->setContext( $this->context ); // Apply the same transformation as done in RecentChange::getIRCLine for rc_comment $ircRcComment = RecentChange::cleanupForIRC( $formatter->getIRCActionComment() );