Index: trunk/phase3/includes/SeleniumWebSettings.php |
— | — | @@ -43,17 +43,18 @@ |
44 | 44 | $testResourceFiles = array(); // an array containing all the resource files needed for this test |
45 | 45 | $callback = $wgSeleniumTestConfigs[$setupTestSuiteName]; |
46 | 46 | call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles)); |
| 47 | + |
| 48 | + if ( isset($testResourceFiles['images']) ) { |
| 49 | + $testImageZip = $testResourceFiles['images']; |
| 50 | + } |
47 | 51 | |
48 | 52 | if ( isset( $testResourceFiles['db'] ) ) { |
49 | 53 | $testSqlFile = $testResourceFiles['db']; |
| 54 | + $testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName ); |
| 55 | + |
| 56 | + switchToTestResources( $testResourceName, false ); // false means do not switch database yet |
| 57 | + setupTestResources( $testResourceName, $testSqlFile, $testImageZip ); |
50 | 58 | } |
51 | | - if ( isset($testResourceFiles['images']) ) { |
52 | | - $testImageZip = $testResourceFiles['images']; |
53 | | - } |
54 | | - |
55 | | - $testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName ); |
56 | | - switchToTestResources( $testResourceName, false ); // false means do not switch database yet |
57 | | - setupTestResources( $testResourceName, $testSqlFile, $testImageZip ); |
58 | 59 | } |
59 | 60 | |
60 | 61 | //clear the cookie based on a request param |
— | — | @@ -80,15 +81,16 @@ |
81 | 82 | return; |
82 | 83 | } |
83 | 84 | |
84 | | - $testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName ); |
85 | | - switchToTestResources( $testResourceName ); |
86 | | - |
87 | 85 | $testIncludes = array(); //array containing all the includes needed for this test |
88 | 86 | $testGlobalConfigs = array(); //an array containg all the global configs needed for this test |
89 | 87 | $testResourceFiles = array(); // an array containing all the resource files needed for this test |
90 | 88 | $callback = $wgSeleniumTestConfigs[$testSuiteName]; |
91 | 89 | call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles)); |
92 | | - |
| 90 | + |
| 91 | + if ( isset( $testResourceFiles['db'] ) ) { |
| 92 | + $testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName ); |
| 93 | + switchToTestResources( $testResourceName ); |
| 94 | + } |
93 | 95 | foreach ( $testIncludes as $includeFile ) { |
94 | 96 | $file = $IP . '/' . $includeFile; |
95 | 97 | require_once( $file ); |
— | — | @@ -128,13 +130,10 @@ |
129 | 131 | } |
130 | 132 | |
131 | 133 | function setupTestResources( $testResourceName, $testSqlFile, $testImageZip ) { |
132 | | - global $wgDBname, $wgSeleniumUseTestResources; |
133 | | - |
134 | | - if ( !$wgSeleniumUseTestResources ) { |
135 | | - return false; |
136 | | - } |
| 134 | + global $wgDBname; |
| 135 | + |
137 | 136 | // Basic security. Do not allow to drop productive database. |
138 | | - if ( $testResouceName == $wgDBname ) { |
| 137 | + if ( $testResourceName == $wgDBname ) { |
139 | 138 | die( "Cannot override productive database." ); |
140 | 139 | } |
141 | 140 | if ( $testResourceName == '' ) { |
— | — | @@ -169,11 +168,6 @@ |
170 | 169 | } |
171 | 170 | |
172 | 171 | function teardownTestResources( $testResourceName ) { |
173 | | - global $wgSeleniumUseTestResources; |
174 | | - |
175 | | - if ( !$wgSeleniumUseTestResources ) { |
176 | | - return false; |
177 | | - } |
178 | 172 | // remove test database |
179 | 173 | $dbw =& wfGetDB( DB_MASTER ); |
180 | 174 | $dbw->query( "DROP DATABASE IF EXISTS ".$testResourceName ); |
— | — | @@ -186,21 +180,15 @@ |
187 | 181 | } |
188 | 182 | |
189 | 183 | function switchToTestResources( $testResourceName, $switchDB = true ) { |
190 | | - global $wgDBuser, $wgDBpassword, $wgDBname, $wgDBprefix; |
191 | | - global $wgDBtestuser, $wgDBtestpassword, $wgDBtestprefix; |
| 184 | + global $wgDBuser, $wgDBpassword, $wgDBname; |
| 185 | + global $wgDBtestuser, $wgDBtestpassword; |
192 | 186 | global $wgUploadPath; |
193 | | - global $wgSeleniumUseTestResources; |
194 | | - |
195 | | - if ( !$wgSeleniumUseTestResources ) { |
196 | | - return false; |
197 | | - } |
198 | 187 | |
199 | 188 | if ( $switchDB ) { |
200 | 189 | $wgDBname = $testResourceName; |
201 | 190 | } |
202 | 191 | $wgDBuser = $wgDBtestuser; |
203 | 192 | $wgDBpassword = $wgDBtestpassword; |
204 | | - //$wgDBprefix = $wgDBtestprefix; |
205 | 193 | |
206 | 194 | $testUploadPath = getTestUploadPathFromResourceName( $testResourceName ); |
207 | 195 | $wgUploadPath = $testUploadPath; |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -5263,6 +5263,8 @@ |
5264 | 5264 | $wgEnableSelenium = false; |
5265 | 5265 | $wgSeleniumTestConfigs = array(); |
5266 | 5266 | $wgSeleniumConfigFile = null; |
| 5267 | +$wgDBtestuser = ''; //db user that has permission to create and drop the test databases only |
| 5268 | +$wgDBtestpassword = ''; |
5267 | 5269 | |
5268 | 5270 | /** |
5269 | 5271 | * For really cool vim folding this needs to be at the end: |