Index: trunk/phase3/maintenance/tests/RunSeleniumTests.php |
— | — | @@ -90,21 +90,21 @@ |
91 | 91 | $configFile = $this->getOption( 'seleniumConfig', '' ); |
92 | 92 | if ( strlen( $configFile ) > 0 ) { |
93 | 93 | $this->output("Using Selenium Configuration file: " . $configFile . "\n"); |
94 | | - SeleniumTestConfig::getSeleniumSettings( &$seleniumSettings, |
95 | | - &$seleniumBrowsers, |
96 | | - &$seleniumTestSuites, |
97 | | - $configFile ); |
| 94 | + SeleniumConfig::getSeleniumSettings( $seleniumSettings, |
| 95 | + $seleniumBrowsers, |
| 96 | + $seleniumTestSuites, |
| 97 | + $configFile ); |
98 | 98 | } else if ( !isset( $wgHooks['SeleniumSettings'] ) ) { |
99 | | - $this->output("Using default Selenium Configuration file: selenium_settings.ini in the root directory.\n"); |
100 | | - SeleniumTestConfig::getSeleniumSettings( &$seleniumSettings, |
101 | | - &$seleniumBrowsers, |
102 | | - &$seleniumTestSuites |
| 99 | + $this->output("No command line configuration file or configuration hook found.\n"); |
| 100 | + SeleniumConfig::getSeleniumSettings( $seleniumSettings, |
| 101 | + $seleniumBrowsers, |
| 102 | + $seleniumTestSuites |
103 | 103 | ); |
104 | 104 | } else { |
105 | 105 | $this->output("Using 'SeleniumSettings' hook for configuration.\n"); |
106 | | - wfRunHooks('SeleniumSettings', array( &$seleniumSettings, |
107 | | - &$seleniumBrowsers, |
108 | | - &$seleniumTestSuites ) ); |
| 106 | + wfRunHooks('SeleniumSettings', array( $seleniumSettings, |
| 107 | + $seleniumBrowsers, |
| 108 | + $seleniumTestSuites ) ); |
109 | 109 | } |
110 | 110 | |
111 | 111 | |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php |
— | — | @@ -1,46 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class SeleniumTestConfig { |
5 | | - |
6 | | - /* |
7 | | - * Retreives the Selenium configuration values from an ini file. |
8 | | - * See sample config file in selenium_settings.ini.sample |
9 | | - * |
10 | | - */ |
11 | | - public static function getSeleniumSettings ( &$seleniumSettings, |
12 | | - &$seleniumBrowsers, |
13 | | - &$seleniumTestSuites, |
14 | | - $seleniumConfigFile = null ) { |
15 | | - if ( $seleniumConfigFile == null ) { |
16 | | - global $wgSeleniumConfigFile; |
17 | | - $seleniumConfigFile = ( isset( $wgSeleniumConfigFile ) ) ? |
18 | | - $wgSeleniumConfigFile : dirname( __FILE__ ) . "/../../../selenium_settings.ini"; |
19 | | - } |
20 | | - |
21 | | - if ( !file_exists( $seleniumConfigFile ) ) { |
22 | | - throw new MWException( "Unable to read local Selenium Settings from " . $seleniumConfigFile . "\n" ); |
23 | | - } |
24 | | - |
25 | | - $configArray = parse_ini_file($seleniumConfigFile, true); |
26 | | - if ( array_key_exists( 'SeleniumSettings', $configArray) ) { |
27 | | - wfSuppressWarnings(); |
28 | | - //we may need to change how this is set. But for now leave it in the ini file |
29 | | - $seleniumBrowsers = $configArray['SeleniumSettings']['browsers']; |
30 | | - |
31 | | - $seleniumSettings['host'] = $configArray['SeleniumSettings']['host']; |
32 | | - $seleniumSettings['port'] = $configArray['SeleniumSettings']['port']; |
33 | | - $seleniumSettings['wikiUrl'] = $configArray['SeleniumSettings']['wikiUrl']; |
34 | | - $seleniumSettings['username'] = $configArray['SeleniumSettings']['username']; |
35 | | - $seleniumSettings['userPassword'] = $configArray['SeleniumSettings']['userPassword']; |
36 | | - $seleniumSettings['testBrowser'] = $configArray['SeleniumSettings']['testBrowser']; |
37 | | - wfRestoreWarnings(); |
38 | | - } |
39 | | - if ( array_key_exists( 'SeleniumTests', $configArray) ) { |
40 | | - wfSuppressWarnings(); |
41 | | - $seleniumTestSuites = $configArray['SeleniumTests']['testSuite']; |
42 | | - wfRestoreWarnings(); |
43 | | - } |
44 | | - return true; |
45 | | - } |
46 | | - |
47 | | -} |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +<?php |
| 3 | +if ( !defined( 'SELENIUMTEST' ) ) { |
| 4 | + die( 1 ); |
| 5 | +} |
| 6 | + |
| 7 | +class SeleniumConfig { |
| 8 | + |
| 9 | + /* |
| 10 | + * Retreives the Selenium configuration values from an ini file. |
| 11 | + * See sample config file in selenium_settings.ini.sample |
| 12 | + * |
| 13 | + */ |
| 14 | + public static function getSeleniumSettings ( &$seleniumSettings, |
| 15 | + &$seleniumBrowsers, |
| 16 | + &$seleniumTestSuites, |
| 17 | + $seleniumConfigFile = null ) { |
| 18 | + if ( strlen( $seleniumConfigFile ) == 0 ) { |
| 19 | + global $wgSeleniumConfigFile; |
| 20 | + if ( isset( $wgSeleniumConfigFile ) ) $seleniumConfigFile = $wgSeleniumConfigFile ; |
| 21 | + } |
| 22 | + |
| 23 | + if ( strlen( $seleniumConfigFile ) == 0 || !file_exists( $seleniumConfigFile ) ) { |
| 24 | + throw new MWException( "Unable to read local Selenium Settings from " . $seleniumConfigFile . "\n" ); |
| 25 | + } |
| 26 | + |
| 27 | + $configArray = parse_ini_file($seleniumConfigFile, true); |
| 28 | + if ( array_key_exists( 'SeleniumSettings', $configArray) ) { |
| 29 | + wfSuppressWarnings(); |
| 30 | + //we may need to change how this is set. But for now leave it in the ini file |
| 31 | + $seleniumBrowsers = $configArray['SeleniumSettings']['browsers']; |
| 32 | + |
| 33 | + $seleniumSettings['host'] = $configArray['SeleniumSettings']['host']; |
| 34 | + $seleniumSettings['port'] = $configArray['SeleniumSettings']['port']; |
| 35 | + $seleniumSettings['wikiUrl'] = $configArray['SeleniumSettings']['wikiUrl']; |
| 36 | + $seleniumSettings['username'] = $configArray['SeleniumSettings']['username']; |
| 37 | + $seleniumSettings['userPassword'] = $configArray['SeleniumSettings']['userPassword']; |
| 38 | + $seleniumSettings['testBrowser'] = $configArray['SeleniumSettings']['testBrowser']; |
| 39 | + wfRestoreWarnings(); |
| 40 | + } |
| 41 | + if ( array_key_exists( 'SeleniumTests', $configArray) ) { |
| 42 | + wfSuppressWarnings(); |
| 43 | + $seleniumTestSuites = $configArray['SeleniumTests']['testSuite']; |
| 44 | + wfRestoreWarnings(); |
| 45 | + } |
| 46 | + return true; |
| 47 | + } |
| 48 | + |
| 49 | +} |
Index: trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class SeleniumConfigurationTest extends PHPUnit_Framework_TestCase { |
5 | | - |
| 5 | + |
6 | 6 | /* |
7 | 7 | * The file where the test temporarity stores the selenium config. |
8 | 8 | * This should be cleaned up as part of teardown. |
— | — | @@ -84,6 +84,12 @@ |
85 | 85 | */ |
86 | 86 | private $testSuites1 = null; |
87 | 87 | |
| 88 | + |
| 89 | + public function setUp() { |
| 90 | + if ( !defined( 'SELENIUMTEST' ) ) { |
| 91 | + define( 'SELENIUMTEST', true ); |
| 92 | + } |
| 93 | + } |
88 | 94 | |
89 | 95 | /* |
90 | 96 | * Clean up the temporary file used to sore the selenium settings. |
— | — | @@ -99,39 +105,73 @@ |
100 | 106 | /** |
101 | 107 | * @expectedException MWException |
102 | 108 | * @group SeleniumFramework |
103 | | - * This test will throw warnings unless you have the following setting in your php.ini |
104 | | - * allow_call_time_pass_reference = On |
105 | 109 | */ |
106 | | - public function testErrorOnMissingConfigFile() { |
| 110 | + public function testErrorOnIncorrectConfigFile() { |
107 | 111 | $seleniumSettings; |
108 | 112 | $seleniumBrowsers; |
109 | 113 | $seleniumTestSuites; |
110 | 114 | |
111 | | - SeleniumTestConfig::getSeleniumSettings($seleniumSettings, |
112 | | - $seleniumBrowsers, |
113 | | - $seleniumTestSuites, |
114 | | - "Some_fake_settings_file.ini" ); |
| 115 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 116 | + $seleniumBrowsers, |
| 117 | + $seleniumTestSuites, |
| 118 | + "Some_fake_settings_file.ini" ); |
| 119 | + |
115 | 120 | } |
116 | 121 | |
117 | 122 | /** |
| 123 | + * @expectedException MWException |
118 | 124 | * @group SeleniumFramework |
| 125 | + */ |
| 126 | + public function testErrorOnMissingConfigFile() { |
| 127 | + $seleniumSettings; |
| 128 | + $seleniumBrowsers; |
| 129 | + $seleniumTestSuites; |
| 130 | + global $wgSeleniumConfigFile; |
| 131 | + $wgSeleniumConfigFile = ''; |
| 132 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 133 | + $seleniumBrowsers, |
| 134 | + $seleniumTestSuites); |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * @group SeleniumFramework |
| 139 | + */ |
| 140 | + public function testUsesGlobalVarForConfigFile() { |
| 141 | + $seleniumSettings; |
| 142 | + $seleniumBrowsers; |
| 143 | + $seleniumTestSuites; |
| 144 | + global $wgSeleniumConfigFile; |
| 145 | + $this->writeToTempFile( $this->testConfig0 ); |
| 146 | + $wgSeleniumConfigFile = $this->tempFileName; |
| 147 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 148 | + $seleniumBrowsers, |
| 149 | + $seleniumTestSuites); |
| 150 | + $this->assertEquals($seleniumSettings, $this->testSettings0 , |
| 151 | + 'The selenium settings should have been read from the file defined in $wgSeleniumConfigFile' |
| 152 | + ); |
| 153 | + $this->assertEquals($seleniumBrowsers, $this->testBrowsers0, |
| 154 | + 'The available browsers should have been read from the file defined in $wgSeleniumConfigFile' |
| 155 | + ); |
| 156 | + $this->assertEquals($seleniumTestSuites, $this->testSuites0, |
| 157 | + 'The test suites should have been read from the file defined in $wgSeleniumConfigFile' |
| 158 | + ); |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * @group SeleniumFramework |
119 | 163 | * @dataProvider sampleConfigs |
120 | | - * This test will throw warnings unless you have the following setting in your php.ini |
121 | | - * allow_call_time_pass_reference = On |
122 | 164 | */ |
123 | 165 | public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) { |
124 | | - //print "SAMPLE_CONFIG " . $sampleConfig . "\n\n"; |
125 | 166 | $this->writeToTempFile( $sampleConfig ); |
126 | 167 | $seleniumSettings; |
127 | 168 | $seleniumBrowsers; |
128 | 169 | $seleniumTestSuites; |
129 | 170 | |
130 | | - SeleniumTestConfig::getSeleniumSettings($seleniumSettings, |
131 | | - $seleniumBrowsers, |
132 | | - $seleniumTestSuites, |
133 | | - $this->tempFileName ); |
134 | | - |
135 | | - |
| 171 | + SeleniumConfig::getSeleniumSettings($seleniumSettings, |
| 172 | + $seleniumBrowsers, |
| 173 | + $seleniumTestSuites, |
| 174 | + $this->tempFileName ); |
| 175 | + |
136 | 176 | $this->assertEquals($seleniumSettings, $expectedSettings, |
137 | 177 | "The selenium settings for the following test configuration was not retrieved correctly" . $sampleConfig |
138 | 178 | ); |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -710,7 +710,7 @@ |
711 | 711 | 'SeleniumTestHTMLLogger' => 'maintenance/tests/selenium/SeleniumTestHTMLLogger.php', |
712 | 712 | 'SeleniumTestListener' => 'maintenance/tests/selenium/SeleniumTestListener.php', |
713 | 713 | 'SeleniumTestSuite' => 'maintenance/tests/selenium/SeleniumTestSuite.php', |
714 | | - 'SeleniumTestConfig' => 'maintenance/tests/selenium/SeleniumTestConfig.php', |
| 714 | + 'SeleniumConfig' => 'maintenance/tests/selenium/SeleniumConfig.php', |
715 | 715 | |
716 | 716 | # maintenance/language |
717 | 717 | 'csvStatsOutput' => 'maintenance/language/StatOutputs.php', |