https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112281

Revision: 112281
Author:   krinkle
Date:     2012-02-24 01:00:54 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
[JSTesting] mock/restore mw.messages as well, like mw.config

Modified Paths:
--------------
    trunk/phase3/tests/qunit/data/testrunner.js

Modified: trunk/phase3/tests/qunit/data/testrunner.js
===================================================================
--- trunk/phase3/tests/qunit/data/testrunner.js 2012-02-24 00:49:28 UTC (rev 
112280)
+++ trunk/phase3/tests/qunit/data/testrunner.js 2012-02-24 01:00:54 UTC (rev 
112281)
@@ -105,37 +105,45 @@
  * </code>
  */
 QUnit.newMwEnvironment = ( function () {
-       var liveConfig, freshConfigCopy, log;
+       var log, liveConfig, liveMsgs;
 
        liveConfig = mw.config.values;
+       liveMsgs = mw.messages.values;
 
-       freshConfigCopy = function ( custom ) {
+       function freshConfigCopy( custom ) {
                // "deep=true" is important here.
                // Otherwise we just create a new object with values referring 
to live config.
                // e.g. mw.config.set( 'wgFileExtensions', [] ) would not 
effect liveConfig,
                // but mw.config.get( 'wgFileExtensions' ).push( 'png' ) would 
as the array
                // was passed by reference in $.extend's loop.
                return $.extend({}, liveConfig, custom, /*deep=*/true );
-       };
+       }
 
+       function freshMsgsCopy( custom ) {
+               return $.extend({}, liveMsgs, custom, /*deep=*/true );
+       }
+
        log = QUnit.urlParams.mwlogenv ? mw.log : function () {};
 
-       return function ( override ) {
-               override = override || {};
+       return function ( overrideConfig, overrideMsgs ) {
+               overrideConfig = overrideConfig || {};
+               overrideMsgs = overrideMsgs || {};
 
                return {
                        setup: function () {
                                log( 'MwEnvironment> SETUP    for "' + 
QUnit.config.current.module
                                        + ': ' + QUnit.config.current.testName 
+ '"' );
-                               // Greetings, mock configuration!
-                               mw.config.values = freshConfigCopy( override );
+                               // Greetings, mock environment!
+                               mw.config.values = freshConfigCopy( 
overrideConfig );
+                               mw.messages.values = freshMsgsCopy( 
overrideMsgs );
                        },
 
                        teardown: function () {
                                log( 'MwEnvironment> TEARDOWN for "' + 
QUnit.config.current.module
                                        + ': ' + QUnit.config.current.testName 
+ '"' );
-                               // Farewell, mock configuration!
+                               // Farewell, mock environment!
                                mw.config.values = liveConfig;
+                               mw.messages.values = liveMsgs;
                        }
                };
        };


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to