From: Priyanka Dhanda Date: Tue, 11 Jan 2011 00:36:36 +0000 (+0000) Subject: Follow up to #79421. Cleaned up some globals and some typos. Going to follow up with... X-Git-Tag: 1.31.0-rc.0~32637 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=14e14c6e047c5a9931bf1f916c773b60bca7a17b;p=lhc%2Fweb%2Fwiklou.git Follow up to #79421. Cleaned up some globals and some typos. Going to follow up with some actual test changes --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 7913683086..43d5150588 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -5263,6 +5263,8 @@ $wgUploadMaintenance = false; $wgEnableSelenium = false; $wgSeleniumTestConfigs = array(); $wgSeleniumConfigFile = null; +$wgDBtestuser = ''; //db user that has permission to create and drop the test databases only +$wgDBtestpassword = ''; /** * For really cool vim folding this needs to be at the end: diff --git a/includes/SeleniumWebSettings.php b/includes/SeleniumWebSettings.php index 7a838e9a7a..a19539d431 100644 --- a/includes/SeleniumWebSettings.php +++ b/includes/SeleniumWebSettings.php @@ -43,17 +43,18 @@ if ( isset( $_GET['setupTestSuite'] ) ) { $testResourceFiles = array(); // an array containing all the resource files needed for this test $callback = $wgSeleniumTestConfigs[$setupTestSuiteName]; call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles)); + + if ( isset($testResourceFiles['images']) ) { + $testImageZip = $testResourceFiles['images']; + } if ( isset( $testResourceFiles['db'] ) ) { $testSqlFile = $testResourceFiles['db']; + $testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName ); + + switchToTestResources( $testResourceName, false ); // false means do not switch database yet + setupTestResources( $testResourceName, $testSqlFile, $testImageZip ); } - if ( isset($testResourceFiles['images']) ) { - $testImageZip = $testResourceFiles['images']; - } - - $testResourceName = getTestResourceNameFromTestSuiteName( $setupTestSuiteName ); - switchToTestResources( $testResourceName, false ); // false means do not switch database yet - setupTestResources( $testResourceName, $testSqlFile, $testImageZip ); } //clear the cookie based on a request param @@ -80,15 +81,16 @@ if ( isset( $_COOKIE[$cookieName] ) ) { return; } - $testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName ); - switchToTestResources( $testResourceName ); - $testIncludes = array(); //array containing all the includes needed for this test $testGlobalConfigs = array(); //an array containg all the global configs needed for this test $testResourceFiles = array(); // an array containing all the resource files needed for this test $callback = $wgSeleniumTestConfigs[$testSuiteName]; call_user_func_array( $callback, array( &$testIncludes, &$testGlobalConfigs, &$testResourceFiles)); - + + if ( isset( $testResourceFiles['db'] ) ) { + $testResourceName = getTestResourceNameFromTestSuiteName( $testSuiteName ); + switchToTestResources( $testResourceName ); + } foreach ( $testIncludes as $includeFile ) { $file = $IP . '/' . $includeFile; require_once( $file ); @@ -128,13 +130,10 @@ function getTestUploadPathFromResourceName( $testResourceName ) { } function setupTestResources( $testResourceName, $testSqlFile, $testImageZip ) { - global $wgDBname, $wgSeleniumUseTestResources; - - if ( !$wgSeleniumUseTestResources ) { - return false; - } + global $wgDBname; + // Basic security. Do not allow to drop productive database. - if ( $testResouceName == $wgDBname ) { + if ( $testResourceName == $wgDBname ) { die( "Cannot override productive database." ); } if ( $testResourceName == '' ) { @@ -169,11 +168,6 @@ function setupTestResources( $testResourceName, $testSqlFile, $testImageZip ) { } function teardownTestResources( $testResourceName ) { - global $wgSeleniumUseTestResources; - - if ( !$wgSeleniumUseTestResources ) { - return false; - } // remove test database $dbw =& wfGetDB( DB_MASTER ); $dbw->query( "DROP DATABASE IF EXISTS ".$testResourceName ); @@ -186,21 +180,15 @@ function teardownTestResources( $testResourceName ) { } function switchToTestResources( $testResourceName, $switchDB = true ) { - global $wgDBuser, $wgDBpassword, $wgDBname, $wgDBprefix; - global $wgDBtestuser, $wgDBtestpassword, $wgDBtestprefix; + global $wgDBuser, $wgDBpassword, $wgDBname; + global $wgDBtestuser, $wgDBtestpassword; global $wgUploadPath; - global $wgSeleniumUseTestResources; - - if ( !$wgSeleniumUseTestResources ) { - return false; - } if ( $switchDB ) { $wgDBname = $testResourceName; } $wgDBuser = $wgDBtestuser; $wgDBpassword = $wgDBtestpassword; - //$wgDBprefix = $wgDBtestprefix; $testUploadPath = getTestUploadPathFromResourceName( $testResourceName ); $wgUploadPath = $testUploadPath;