http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74750
Revision: 74750 Author: mglaser Date: 2010-10-13 23:52:42 +0000 (Wed, 13 Oct 2010) Log Message: ----------- * handle PHP 5.2 ini files * sample ini file for PHP 5.2 * credits to dan nessett Modified Paths: -------------- trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php Added Paths: ----------- trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample Modified: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php =================================================================== --- trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php 2010-10-13 23:52:37 UTC (rev 74749) +++ trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php 2010-10-13 23:52:42 UTC (rev 74750) @@ -10,6 +10,7 @@ * See sample config file in selenium_settings.ini.sample * */ + public static function getSeleniumSettings ( &$seleniumSettings, &$seleniumBrowsers, &$seleniumTestSuites, @@ -23,7 +24,16 @@ throw new MWException( "Unable to read local Selenium Settings from " . $seleniumConfigFile . "\n" ); } - $configArray = parse_ini_file($seleniumConfigFile, true); + if ( !defined( 'PHP_VERSION_ID' ) || + ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3 ) ) { + $configArray = self::parse_5_2_ini_file( $seleniumConfigFile ); + } else { + $configArray = parse_ini_file( $seleniumConfigFile, true ); + } + if ( $configArray === false ) { + throw new MWException( "Error parsing " . $seleniumConfigFile . "\n" ); + } + if ( array_key_exists( 'SeleniumSettings', $configArray) ) { wfSuppressWarnings(); //we may need to change how this is set. But for now leave it in the ini file @@ -45,4 +55,28 @@ return true; } + private static function parse_5_2_ini_file ( $ConfigFile ) { + + $configArray = parse_ini_file( $ConfigFile, true ); + if ( $configArray === false ) return false; + + // PHP 5.2 ini files have [browsers] and [testSuite] sections + // to get around lack of support for array keys. It then + // inserts the section arrays into the appropriate places in + // the SeleniumSettings and SeleniumTests arrays. + + if ( isset( $configArray[browsers] ) ) { + $configArray[SeleniumSettings][browsers] = $configArray[browsers]; + unset ( $configArray[browsers] ); + } + + if ( isset( $configArray[testSuite] ) ) { + $configArray[SeleniumTests][testSuite] = $configArray[testSuite]; + unset ( $configArray[testSuite] ); + } + + return $configArray; + + } + } Added: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample =================================================================== --- trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample (rev 0) +++ trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample 2010-10-13 23:52:42 UTC (rev 74750) @@ -0,0 +1,19 @@ +[browsers] + +firefox = "*firefox" +iexploreproxy = "*iexploreproxy" +chrome = "*chrome" + +[SeleniumSettings] + +host = "localhost" +port = "4444" +wikiUrl = "http://localhost/mediawiki/latest_trunk/trunk/phase3" +username = "Wikiadmin" +userPassword = "Wikiadminpw" +testBrowser = "firefox" + +[testSuite] + +SimpleSeleniumTestSuite = "maintenance/tests/selenium/SimpleSeleniumTestSuite.php" +PagedTiffHandlerSeleniumTestSuite = "extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestSuite.php" _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs