r112281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112280‎ | r112281 | r112282 >
Date:01:00, 24 February 2012
Author:krinkle
Status:ok
Tags:
Comment:
[JSTesting] mock/restore mw.messages as well, like mw.config
Modified paths:
  • /trunk/phase3/tests/qunit/data/testrunner.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/data/testrunner.js
@@ -105,37 +105,45 @@
106106 * </code>
107107 */
108108 QUnit.newMwEnvironment = ( function () {
109 - var liveConfig, freshConfigCopy, log;
 109+ var log, liveConfig, liveMsgs;
110110
111111 liveConfig = mw.config.values;
 112+ liveMsgs = mw.messages.values;
112113
113 - freshConfigCopy = function ( custom ) {
 114+ function freshConfigCopy( custom ) {
114115 // "deep=true" is important here.
115116 // Otherwise we just create a new object with values referring to live config.
116117 // e.g. mw.config.set( 'wgFileExtensions', [] ) would not effect liveConfig,
117118 // but mw.config.get( 'wgFileExtensions' ).push( 'png' ) would as the array
118119 // was passed by reference in $.extend's loop.
119120 return $.extend({}, liveConfig, custom, /*deep=*/true );
120 - };
 121+ }
121122
 123+ function freshMsgsCopy( custom ) {
 124+ return $.extend({}, liveMsgs, custom, /*deep=*/true );
 125+ }
 126+
122127 log = QUnit.urlParams.mwlogenv ? mw.log : function () {};
123128
124 - return function ( override ) {
125 - override = override || {};
 129+ return function ( overrideConfig, overrideMsgs ) {
 130+ overrideConfig = overrideConfig || {};
 131+ overrideMsgs = overrideMsgs || {};
126132
127133 return {
128134 setup: function () {
129135 log( 'MwEnvironment> SETUP for "' + QUnit.config.current.module
130136 + ': ' + QUnit.config.current.testName + '"' );
131 - // Greetings, mock configuration!
132 - mw.config.values = freshConfigCopy( override );
 137+ // Greetings, mock environment!
 138+ mw.config.values = freshConfigCopy( overrideConfig );
 139+ mw.messages.values = freshMsgsCopy( overrideMsgs );
133140 },
134141
135142 teardown: function () {
136143 log( 'MwEnvironment> TEARDOWN for "' + QUnit.config.current.module
137144 + ': ' + QUnit.config.current.testName + '"' );
138 - // Farewell, mock configuration!
 145+ // Farewell, mock environment!
139146 mw.config.values = liveConfig;
 147+ mw.messages.values = liveMsgs;
140148 }
141149 };
142150 };

Follow-up revisions

RevisionCommit summaryAuthorDate
r112368[JSTesting] Add more mw.loader tests...krinkle23:13, 24 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112279[JSTesting] Refactor mw.loader test to be more extendablekrinkle00:44, 24 February 2012

Status & tagging log