Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/348248 )

Change subject: phpunit: Make LogFormatterTest less slow
......................................................................

phpunit: Make LogFormatterTest less slow

Right now it's quite slow because it reloads LocalisationCache
for every test case.

Change the reload to only happen once for the entire class.

Also use RequestContext instead of wgLang to match logic in
the parent class (MediaWikiLangTestCase).

Change-Id: Ia791563ca9094c36782acfe9826def45f2a1d621
---
M tests/phpunit/includes/logging/LogFormatterTest.php
1 file changed, 19 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/348248/1

diff --git a/tests/phpunit/includes/logging/LogFormatterTest.php 
b/tests/phpunit/includes/logging/LogFormatterTest.php
index c2b791e..1ef3df6 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,20 +31,32 @@
         */
        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' );
@@ -52,16 +65,9 @@
                $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 = '<User comment about action>';
-       }
-
-       protected function tearDown() {
-               parent::tearDown();
-
-               global $wgLang;
-               Language::getLocalisationCache()->recache( $wgLang->getCode() );
        }
 
        public function newLogEntry( $action, $params ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/348248
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia791563ca9094c36782acfe9826def45f2a1d621
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to