Index: trunk/phase3/tests/selenium/selenium_settings.ini.php52.sample |
— | — | @@ -1,23 +0,0 @@ |
2 | | -[browsers] |
3 | | - |
4 | | -firefox = "*firefox" |
5 | | -iexploreproxy = "*iexploreproxy" |
6 | | -chrome = "*chrome" |
7 | | - |
8 | | -[SeleniumSettings] |
9 | | - |
10 | | -host = "localhost" |
11 | | -port = "4444" |
12 | | -wikiUrl = "http://localhost/mediawiki/latest_trunk/trunk/phase3" |
13 | | -username = "Wikiadmin" |
14 | | -userPassword = "Wikiadminpw" |
15 | | -testBrowser = "firefox" |
16 | | -startserver = |
17 | | -stopserver = |
18 | | -jUnitLogFile = |
19 | | -runAgainstGrid = false |
20 | | - |
21 | | -[testSuite] |
22 | | - |
23 | | -SimpleSeleniumTestSuite = "tests/selenium/suites/SimpleSeleniumTestSuite.php" |
24 | | -WikiEditorTestSuite = "extensions/WikiEditor/selenium/WikiEditorTestSuite.php" |
Index: trunk/phase3/tests/selenium/selenium_settings_grid.ini.sample |
— | — | @@ -9,6 +9,6 @@ |
10 | 10 | jUnitLogFile = |
11 | 11 | runAgainstGrid = true |
12 | 12 | |
13 | | -[testSuite] |
| 13 | +[SeleniumTests] |
14 | 14 | |
15 | | -SimpleSeleniumTestSuite = "tests/selenium/suites/SimpleSeleniumTestSuite.php" |
\ No newline at end of file |
| 15 | +testSuite[SimpleSeleniumTestSuite] = "tests/selenium/suites/SimpleSeleniumTestSuite.php" |
Index: trunk/phase3/tests/selenium/SeleniumConfig.php |
— | — | @@ -61,28 +61,54 @@ |
62 | 62 | return true; |
63 | 63 | } |
64 | 64 | |
65 | | - private static function parse_5_2_ini_file ( $ConfigFile ) { |
66 | | - |
67 | | - $configArray = parse_ini_file( $ConfigFile, true ); |
68 | | - if ( $configArray === false ) return false; |
69 | | - |
70 | | - // PHP 5.2 ini files have [browsers] and [testSuite] sections |
71 | | - // to get around lack of support for array keys. It then |
72 | | - // inserts the section arrays into the appropriate places in |
73 | | - // the SeleniumSettings and SeleniumTests arrays. |
74 | | - |
75 | | - if ( isset( $configArray['browsers'] ) ) { |
76 | | - $configArray['SeleniumSettings']['browsers'] = $configArray['browsers']; |
77 | | - unset ( $configArray['browsers'] ); |
| 65 | + /** |
| 66 | + * PHP 5.2 parse_ini_file() doesn't have support for array keys. |
| 67 | + * This function parses simple ini files with such syntax using just |
| 68 | + * 5.2 functions. |
| 69 | + */ |
| 70 | + private static function parse_5_2_ini_file( $ConfigFile ) { |
| 71 | + $file = fopen( $ConfigFile, "rt" ); |
| 72 | + if ( !$file ) { |
| 73 | + return false; |
78 | 74 | } |
79 | | - |
80 | | - if ( isset( $configArray['testSuite'] ) ) { |
81 | | - $configArray['SeleniumTests']['testSuite'] = $configArray['testSuite']; |
82 | | - unset ( $configArray['testSuite'] ); |
| 75 | + $header = ''; |
| 76 | + |
| 77 | + $configArray = array(); |
| 78 | + |
| 79 | + while ( ( $line = fgets( $file ) ) !== false ) { |
| 80 | + $line = strtok( $line, "\r\n" ); |
| 81 | + |
| 82 | + if ( !$line || $line[0] == ';' ) continue; |
| 83 | + |
| 84 | + if ( $line[0] == '[' && substr( $line, -1 ) == ']' ) { |
| 85 | + $header = substr( $line, 1, -1 ); |
| 86 | + $configArray[$header] = array(); |
| 87 | + } else { |
| 88 | + $configArray[$header] = array_merge_recursive( $configArray[$header], self::parse_ini_line( $line ) ); |
| 89 | + } |
83 | 90 | } |
84 | | - |
| 91 | + var_dump($configArray); |
85 | 92 | return $configArray; |
| 93 | + } |
86 | 94 | |
| 95 | + private static function parse_ini_line( $iniLine ) { |
| 96 | + static $specialValues = array( 'false' => false, 'true' => true, 'null' => null ); |
| 97 | + list( $key, $value ) = explode( '=', $iniLine, 2 ); |
| 98 | + $key = trim( $key ); |
| 99 | + $value = trim( $value ); |
| 100 | + |
| 101 | + if ( isset( $specialValues[$value] ) ) { |
| 102 | + $value = $specialValues[$value]; |
| 103 | + } else { |
| 104 | + $value = trim( $value, '"' ); |
| 105 | + } |
| 106 | + |
| 107 | + /* Support one-level arrays */ |
| 108 | + if ( preg_match( '/^([A-Za-z]+)\[([A-Za-z]+)\]/', $key, $m ) ) { |
| 109 | + $key = $m[1]; |
| 110 | + $value = array( $m[2] => $value ); |
| 111 | + } |
| 112 | + |
| 113 | + return array( $key => $value ); |
87 | 114 | } |
88 | | - |
89 | 115 | } |