r73574 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73573‎ | r73574 | r73575 >
Date:21:23, 22 September 2010
Author:pdhanda
Status:ok
Tags:
Comment:
Followup to r73500. SeleniumTestConfig renamed to SeleniumConfig. Make sure SELENIUMTEST is defined to use it.
Fixed some indents and pass by reference warnings
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/maintenance/tests/RunSeleniumTests.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php (added) (history)
  • /trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php (deleted) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/RunSeleniumTests.php
@@ -90,21 +90,21 @@
9191 $configFile = $this->getOption( 'seleniumConfig', '' );
9292 if ( strlen( $configFile ) > 0 ) {
9393 $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 );
9898 } 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
103103 );
104104 } else {
105105 $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 ) );
109109 }
110110
111111
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 @@
22 <?php
33
44 class SeleniumConfigurationTest extends PHPUnit_Framework_TestCase {
5 -
 5+
66 /*
77 * The file where the test temporarity stores the selenium config.
88 * This should be cleaned up as part of teardown.
@@ -84,6 +84,12 @@
8585 */
8686 private $testSuites1 = null;
8787
 88+
 89+ public function setUp() {
 90+ if ( !defined( 'SELENIUMTEST' ) ) {
 91+ define( 'SELENIUMTEST', true );
 92+ }
 93+ }
8894
8995 /*
9096 * Clean up the temporary file used to sore the selenium settings.
@@ -99,39 +105,73 @@
100106 /**
101107 * @expectedException MWException
102108 * @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
105109 */
106 - public function testErrorOnMissingConfigFile() {
 110+ public function testErrorOnIncorrectConfigFile() {
107111 $seleniumSettings;
108112 $seleniumBrowsers;
109113 $seleniumTestSuites;
110114
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+
115120 }
116121
117122 /**
 123+ * @expectedException MWException
118124 * @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
119163 * @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
122164 */
123165 public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) {
124 - //print "SAMPLE_CONFIG " . $sampleConfig . "\n\n";
125166 $this->writeToTempFile( $sampleConfig );
126167 $seleniumSettings;
127168 $seleniumBrowsers;
128169 $seleniumTestSuites;
129170
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+
136176 $this->assertEquals($seleniumSettings, $expectedSettings,
137177 "The selenium settings for the following test configuration was not retrieved correctly" . $sampleConfig
138178 );
Index: trunk/phase3/includes/AutoLoader.php
@@ -710,7 +710,7 @@
711711 'SeleniumTestHTMLLogger' => 'maintenance/tests/selenium/SeleniumTestHTMLLogger.php',
712712 'SeleniumTestListener' => 'maintenance/tests/selenium/SeleniumTestListener.php',
713713 'SeleniumTestSuite' => 'maintenance/tests/selenium/SeleniumTestSuite.php',
714 - 'SeleniumTestConfig' => 'maintenance/tests/selenium/SeleniumTestConfig.php',
 714+ 'SeleniumConfig' => 'maintenance/tests/selenium/SeleniumConfig.php',
715715
716716 # maintenance/language
717717 'csvStatsOutput' => 'maintenance/language/StatOutputs.php',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73500RunSeleniumTests.php: Cleaned up a few options that this script takes. Settin...pdhanda00:16, 22 September 2010

Status & tagging log