MediaWiki
REL1_21
|
00001 <?php 00002 if ( !defined( 'SELENIUMTEST' ) ) { 00003 die( 1 ); 00004 } 00005 00006 class SeleniumConfig { 00007 00013 public static function getSeleniumSettings( &$seleniumSettings, 00014 &$seleniumBrowsers, 00015 &$seleniumTestSuites, 00016 $seleniumConfigFile = null ) { 00017 if ( strlen( $seleniumConfigFile ) == 0 ) { 00018 global $wgSeleniumConfigFile; 00019 if ( isset( $wgSeleniumConfigFile ) ) { 00020 $seleniumConfigFile = $wgSeleniumConfigFile; 00021 } 00022 } 00023 00024 if ( strlen( $seleniumConfigFile ) == 0 || !file_exists( $seleniumConfigFile ) ) { 00025 throw new MWException( "Unable to read local Selenium Settings from " . $seleniumConfigFile . "\n" ); 00026 } 00027 00028 $configArray = parse_ini_file( $seleniumConfigFile, true ); 00029 if ( $configArray === false ) { 00030 throw new MWException( "Error parsing " . $seleniumConfigFile . "\n" ); 00031 } 00032 00033 if ( array_key_exists( 'SeleniumSettings', $configArray ) ) { 00034 wfSuppressWarnings(); 00035 //we may need to change how this is set. But for now leave it in the ini file 00036 $seleniumBrowsers = $configArray['SeleniumSettings']['browsers']; 00037 00038 $seleniumSettings['host'] = $configArray['SeleniumSettings']['host']; 00039 $seleniumSettings['port'] = $configArray['SeleniumSettings']['port']; 00040 $seleniumSettings['wikiUrl'] = $configArray['SeleniumSettings']['wikiUrl']; 00041 $seleniumSettings['username'] = $configArray['SeleniumSettings']['username']; 00042 $seleniumSettings['userPassword'] = $configArray['SeleniumSettings']['userPassword']; 00043 $seleniumSettings['testBrowser'] = $configArray['SeleniumSettings']['testBrowser']; 00044 $seleniumSettings['startserver'] = $configArray['SeleniumSettings']['startserver']; 00045 $seleniumSettings['stopserver'] = $configArray['SeleniumSettings']['stopserver']; 00046 $seleniumSettings['seleniumserverexecpath'] = $configArray['SeleniumSettings']['seleniumserverexecpath']; 00047 $seleniumSettings['jUnitLogFile'] = $configArray['SeleniumSettings']['jUnitLogFile']; 00048 $seleniumSettings['runAgainstGrid'] = $configArray['SeleniumSettings']['runAgainstGrid']; 00049 00050 wfRestoreWarnings(); 00051 } 00052 if ( array_key_exists( 'SeleniumTests', $configArray ) ) { 00053 wfSuppressWarnings(); 00054 $seleniumTestSuites = $configArray['SeleniumTests']['testSuite']; 00055 wfRestoreWarnings(); 00056 } 00057 return true; 00058 } 00059 00060 private static function parse_ini_line( $iniLine ) { 00061 static $specialValues = array( 'false' => false, 'true' => true, 'null' => null ); 00062 list( $key, $value ) = explode( '=', $iniLine, 2 ); 00063 $key = trim( $key ); 00064 $value = trim( $value ); 00065 00066 if ( isset( $specialValues[$value] ) ) { 00067 $value = $specialValues[$value]; 00068 } else { 00069 $value = trim( $value, '"' ); 00070 } 00071 00072 /* Support one-level arrays */ 00073 if ( preg_match( '/^([A-Za-z]+)\[([A-Za-z]+)\]/', $key, $m ) ) { 00074 $key = $m[1]; 00075 $value = array( $m[2] => $value ); 00076 } 00077 00078 return array( $key => $value ); 00079 } 00080 }