Index: trunk/phase3/tests/qunit/data/testrunner.js |
— | — | @@ -105,37 +105,45 @@ |
106 | 106 | * </code> |
107 | 107 | */ |
108 | 108 | QUnit.newMwEnvironment = ( function () { |
109 | | - var liveConfig, freshConfigCopy, log; |
| 109 | + var log, liveConfig, liveMsgs; |
110 | 110 | |
111 | 111 | liveConfig = mw.config.values; |
| 112 | + liveMsgs = mw.messages.values; |
112 | 113 | |
113 | | - freshConfigCopy = function ( custom ) { |
| 114 | + function freshConfigCopy( custom ) { |
114 | 115 | // "deep=true" is important here. |
115 | 116 | // Otherwise we just create a new object with values referring to live config. |
116 | 117 | // e.g. mw.config.set( 'wgFileExtensions', [] ) would not effect liveConfig, |
117 | 118 | // but mw.config.get( 'wgFileExtensions' ).push( 'png' ) would as the array |
118 | 119 | // was passed by reference in $.extend's loop. |
119 | 120 | return $.extend({}, liveConfig, custom, /*deep=*/true ); |
120 | | - }; |
| 121 | + } |
121 | 122 | |
| 123 | + function freshMsgsCopy( custom ) { |
| 124 | + return $.extend({}, liveMsgs, custom, /*deep=*/true ); |
| 125 | + } |
| 126 | + |
122 | 127 | log = QUnit.urlParams.mwlogenv ? mw.log : function () {}; |
123 | 128 | |
124 | | - return function ( override ) { |
125 | | - override = override || {}; |
| 129 | + return function ( overrideConfig, overrideMsgs ) { |
| 130 | + overrideConfig = overrideConfig || {}; |
| 131 | + overrideMsgs = overrideMsgs || {}; |
126 | 132 | |
127 | 133 | return { |
128 | 134 | setup: function () { |
129 | 135 | log( 'MwEnvironment> SETUP for "' + QUnit.config.current.module |
130 | 136 | + ': ' + 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 ); |
133 | 140 | }, |
134 | 141 | |
135 | 142 | teardown: function () { |
136 | 143 | log( 'MwEnvironment> TEARDOWN for "' + QUnit.config.current.module |
137 | 144 | + ': ' + QUnit.config.current.testName + '"' ); |
138 | | - // Farewell, mock configuration! |
| 145 | + // Farewell, mock environment! |
139 | 146 | mw.config.values = liveConfig; |
| 147 | + mw.messages.values = liveMsgs; |
140 | 148 | } |
141 | 149 | }; |
142 | 150 | }; |