r79982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79981‎ | r79982 | r79983 >
Date:00:36, 11 January 2011
Author:pdhanda
Status:deferred
Tags:
Comment:
Follow up to #79421. Cleaned up some globals and some typos. Going to follow up with some actual test changes
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SeleniumWebSettings.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SeleniumWebSettings.php
@@ -43,17 +43,18 @@
4444 $testResourceFiles = array(); // an array containing all the resource files needed for this test
4545 $callback = $wgSeleniumTestConfigs[$setupTestSuiteName];
4646 call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles));
 47+
 48+ if ( isset($testResourceFiles['images']) ) {
 49+ $testImageZip = $testResourceFiles['images'];
 50+ }
4751
4852 if ( isset( $testResourceFiles['db'] ) ) {
4953 $testSqlFile = $testResourceFiles['db'];
 54+ $testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName );
 55+
 56+ switchToTestResources( $testResourceName, false ); // false means do not switch database yet
 57+ setupTestResources( $testResourceName, $testSqlFile, $testImageZip );
5058 }
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 );
5859 }
5960
6061 //clear the cookie based on a request param
@@ -80,15 +81,16 @@
8182 return;
8283 }
8384
84 - $testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName );
85 - switchToTestResources( $testResourceName );
86 -
8785 $testIncludes = array(); //array containing all the includes needed for this test
8886 $testGlobalConfigs = array(); //an array containg all the global configs needed for this test
8987 $testResourceFiles = array(); // an array containing all the resource files needed for this test
9088 $callback = $wgSeleniumTestConfigs[$testSuiteName];
9189 call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles));
92 -
 90+
 91+ if ( isset( $testResourceFiles['db'] ) ) {
 92+ $testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName );
 93+ switchToTestResources( $testResourceName );
 94+ }
9395 foreach ( $testIncludes as $includeFile ) {
9496 $file = $IP . '/' . $includeFile;
9597 require_once( $file );
@@ -128,13 +130,10 @@
129131 }
130132
131133 function setupTestResources( $testResourceName, $testSqlFile, $testImageZip ) {
132 - global $wgDBname, $wgSeleniumUseTestResources;
133 -
134 - if ( !$wgSeleniumUseTestResources ) {
135 - return false;
136 - }
 134+ global $wgDBname;
 135+
137136 // Basic security. Do not allow to drop productive database.
138 - if ( $testResouceName == $wgDBname ) {
 137+ if ( $testResourceName == $wgDBname ) {
139138 die( "Cannot override productive database." );
140139 }
141140 if ( $testResourceName == '' ) {
@@ -169,11 +168,6 @@
170169 }
171170
172171 function teardownTestResources( $testResourceName ) {
173 - global $wgSeleniumUseTestResources;
174 -
175 - if ( !$wgSeleniumUseTestResources ) {
176 - return false;
177 - }
178172 // remove test database
179173 $dbw =& wfGetDB( DB_MASTER );
180174 $dbw->query( "DROP DATABASE IF EXISTS ".$testResourceName );
@@ -186,21 +180,15 @@
187181 }
188182
189183 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;
192186 global $wgUploadPath;
193 - global $wgSeleniumUseTestResources;
194 -
195 - if ( !$wgSeleniumUseTestResources ) {
196 - return false;
197 - }
198187
199188 if ( $switchDB ) {
200189 $wgDBname = $testResourceName;
201190 }
202191 $wgDBuser = $wgDBtestuser;
203192 $wgDBpassword = $wgDBtestpassword;
204 - //$wgDBprefix = $wgDBtestprefix;
205193
206194 $testUploadPath = getTestUploadPathFromResourceName( $testResourceName );
207195 $wgUploadPath = $testUploadPath;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -5263,6 +5263,8 @@
52645264 $wgEnableSelenium = false;
52655265 $wgSeleniumTestConfigs = array();
52665266 $wgSeleniumConfigFile = null;
 5267+$wgDBtestuser = ''; //db user that has permission to create and drop the test databases only
 5268+$wgDBtestpassword = '';
52675269
52685270 /**
52695271 * For really cool vim folding this needs to be at the end:

Follow-up revisions

RevisionCommit summaryAuthorDate
r79984New test database resource file with some test configuration changes for it. ...pdhanda01:01, 11 January 2011

Status & tagging log