X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flogging%2FLogFormatterTest.php;h=012b0a3aa56f7dd3b97661898920977c10d9c6b8;hb=c8e482371407477ecd4f0a1b5778e565d3963a93;hp=c2b791e79c101202896b59a2eeb66d79ae1bac04;hpb=3635092917533a865ae94a78243caef2cd99d577;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/logging/LogFormatterTest.php b/tests/phpunit/includes/logging/LogFormatterTest.php index c2b791e79c..012b0a3aa5 100644 --- a/tests/phpunit/includes/logging/LogFormatterTest.php +++ b/tests/phpunit/includes/logging/LogFormatterTest.php @@ -4,6 +4,7 @@ * @group Database */ class LogFormatterTest extends MediaWikiLangTestCase { + private static $oldExtMsgFiles; /** * @var User @@ -30,21 +31,33 @@ class LogFormatterTest extends MediaWikiLangTestCase { */ protected $user_comment; + public static function setUpBeforeClass() { + parent::setUpBeforeClass(); + + global $wgExtensionMessagesFiles; + self::$oldExtMsgFiles = $wgExtensionMessagesFiles; + $wgExtensionMessagesFiles['LogTests'] = __DIR__ . '/LogTests.i18n.php'; + Language::getLocalisationCache()->recache( 'en' ); + } + + public static function tearDownAfterClass() { + global $wgExtensionMessagesFiles; + $wgExtensionMessagesFiles = self::$oldExtMsgFiles; + Language::getLocalisationCache()->recache( 'en' ); + + parent::tearDownAfterClass(); + } + protected function setUp() { parent::setUp(); - global $wgLang; - $this->setMwGlobals( [ 'wgLogTypes' => [ 'phpunit' ], 'wgLogActionsHandlers' => [ 'phpunit/test' => 'LogFormatter', 'phpunit/param' => 'LogFormatter' ], 'wgUser' => User::newFromName( 'Testuser' ), - 'wgExtensionMessagesFiles' => [ 'LogTests' => __DIR__ . '/LogTests.i18n.php' ], ] ); - Language::getLocalisationCache()->recache( $wgLang->getCode() ); - $this->user = User::newFromName( 'Testuser' ); $this->title = Title::newFromText( 'SomeTitle' ); $this->target = Title::newFromText( 'TestTarget' ); @@ -52,18 +65,11 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->context = new RequestContext(); $this->context->setUser( $this->user ); $this->context->setTitle( $this->title ); - $this->context->setLanguage( $wgLang ); + $this->context->setLanguage( RequestContext::getMain()->getLanguage() ); $this->user_comment = ''; } - protected function tearDown() { - parent::tearDown(); - - global $wgLang; - Language::getLocalisationCache()->recache( $wgLang->getCode() ); - } - public function newLogEntry( $action, $params ) { $logEntry = new ManualLogEntry( 'phpunit', $action ); $logEntry->setPerformer( $this->user ); @@ -302,6 +308,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { 'key_ns' => NS_PROJECT, 'key_title' => Title::newFromText( 'project:foo' )->getFullText(), ] ], + [ '4:title-link:key', '', [ + 'key_ns' => NS_SPECIAL, + 'key_title' => SpecialPage::getTitleFor( 'Badtitle', '' )->getFullText(), + ] ], [ '4:user:key', 'foo', [ 'key' => 'Foo' ] ], [ '4:user-link:key', 'foo', [ 'key' => 'Foo' ] ], ];