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