http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73574
Revision: 73574
Author: pdhanda
Date: 2010-09-22 21:23:21 +0000 (Wed, 22 Sep 2010)
Log Message:
-----------
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
trunk/phase3/maintenance/tests/RunSeleniumTests.php
trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php
Added Paths:
-----------
trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php
Removed Paths:
-------------
trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php
Modified: trunk/phase3/includes/AutoLoader.php
===================================================================
--- trunk/phase3/includes/AutoLoader.php 2010-09-22 21:15:58 UTC (rev
73573)
+++ trunk/phase3/includes/AutoLoader.php 2010-09-22 21:23:21 UTC (rev
73574)
@@ -710,7 +710,7 @@
'SeleniumTestHTMLLogger' =>
'maintenance/tests/selenium/SeleniumTestHTMLLogger.php',
'SeleniumTestListener' =>
'maintenance/tests/selenium/SeleniumTestListener.php',
'SeleniumTestSuite' =>
'maintenance/tests/selenium/SeleniumTestSuite.php',
- 'SeleniumTestConfig' =>
'maintenance/tests/selenium/SeleniumTestConfig.php',
+ 'SeleniumConfig' => 'maintenance/tests/selenium/SeleniumConfig.php',
# maintenance/language
'csvStatsOutput' => 'maintenance/language/StatOutputs.php',
Modified: trunk/phase3/maintenance/tests/RunSeleniumTests.php
===================================================================
--- trunk/phase3/maintenance/tests/RunSeleniumTests.php 2010-09-22 21:15:58 UTC
(rev 73573)
+++ trunk/phase3/maintenance/tests/RunSeleniumTests.php 2010-09-22 21:23:21 UTC
(rev 73574)
@@ -90,21 +90,21 @@
$configFile = $this->getOption( 'seleniumConfig', '' );
if ( strlen( $configFile ) > 0 ) {
$this->output("Using Selenium Configuration file: " .
$configFile . "\n");
- SeleniumTestConfig::getSeleniumSettings(
&$seleniumSettings,
-
&$seleniumBrowsers,
-
&$seleniumTestSuites,
-
$configFile );
+ SeleniumConfig::getSeleniumSettings( $seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites,
+ $configFile );
} else if ( !isset( $wgHooks['SeleniumSettings'] ) ) {
- $this->output("Using default Selenium Configuration
file: selenium_settings.ini in the root directory.\n");
- SeleniumTestConfig::getSeleniumSettings(
&$seleniumSettings,
-
&$seleniumBrowsers,
-
&$seleniumTestSuites
+ $this->output("No command line configuration file or
configuration hook found.\n");
+ SeleniumConfig::getSeleniumSettings( $seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites
);
} else {
$this->output("Using 'SeleniumSettings' hook for
configuration.\n");
- wfRunHooks('SeleniumSettings', array(
&$seleniumSettings,
-
&$seleniumBrowsers,
-
&$seleniumTestSuites ) );
+ wfRunHooks('SeleniumSettings', array(
$seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites ) );
}
Modified:
trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php
===================================================================
---
trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php
2010-09-22 21:15:58 UTC (rev 73573)
+++
trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php
2010-09-22 21:23:21 UTC (rev 73574)
@@ -1,7 +1,7 @@
<?php
class SeleniumConfigurationTest extends PHPUnit_Framework_TestCase {
-
+
/*
* The file where the test temporarity stores the selenium config.
* This should be cleaned up as part of teardown.
@@ -84,6 +84,12 @@
*/
private $testSuites1 = null;
+
+ public function setUp() {
+ if ( !defined( 'SELENIUMTEST' ) ) {
+ define( 'SELENIUMTEST', true );
+ }
+ }
/*
* Clean up the temporary file used to sore the selenium settings.
@@ -99,39 +105,73 @@
/**
* @expectedException MWException
* @group SeleniumFramework
- * This test will throw warnings unless you have the following setting in
your php.ini
- * allow_call_time_pass_reference = On
*/
- public function testErrorOnMissingConfigFile() {
+ public function testErrorOnIncorrectConfigFile() {
$seleniumSettings;
$seleniumBrowsers;
$seleniumTestSuites;
- SeleniumTestConfig::getSeleniumSettings($seleniumSettings,
-
$seleniumBrowsers,
-
$seleniumTestSuites,
-
"Some_fake_settings_file.ini" );
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites,
+ "Some_fake_settings_file.ini" );
+
}
/**
+ * @expectedException MWException
* @group SeleniumFramework
+ */
+ public function testErrorOnMissingConfigFile() {
+ $seleniumSettings;
+ $seleniumBrowsers;
+ $seleniumTestSuites;
+ global $wgSeleniumConfigFile;
+ $wgSeleniumConfigFile = '';
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites);
+ }
+
+ /**
+ * @group SeleniumFramework
+ */
+ public function testUsesGlobalVarForConfigFile() {
+ $seleniumSettings;
+ $seleniumBrowsers;
+ $seleniumTestSuites;
+ global $wgSeleniumConfigFile;
+ $this->writeToTempFile( $this->testConfig0 );
+ $wgSeleniumConfigFile = $this->tempFileName;
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites);
+ $this->assertEquals($seleniumSettings, $this->testSettings0 ,
+ 'The selenium settings should have been read from the file
defined in $wgSeleniumConfigFile'
+ );
+ $this->assertEquals($seleniumBrowsers, $this->testBrowsers0,
+ 'The available browsers should have been read from the file
defined in $wgSeleniumConfigFile'
+ );
+ $this->assertEquals($seleniumTestSuites, $this->testSuites0,
+ 'The test suites should have been read from the file defined in
$wgSeleniumConfigFile'
+ );
+ }
+
+ /**
+ * @group SeleniumFramework
* @dataProvider sampleConfigs
- * This test will throw warnings unless you have the following setting
in your php.ini
- * allow_call_time_pass_reference = On
*/
public function testgetSeleniumSettings($sampleConfig,
$expectedSettings, $expectedBrowsers, $expectedSuites ) {
- //print "SAMPLE_CONFIG " . $sampleConfig . "\n\n";
$this->writeToTempFile( $sampleConfig );
$seleniumSettings;
$seleniumBrowsers;
$seleniumTestSuites;
- SeleniumTestConfig::getSeleniumSettings($seleniumSettings,
-
$seleniumBrowsers,
-
$seleniumTestSuites,
-
$this->tempFileName );
-
-
+ SeleniumConfig::getSeleniumSettings($seleniumSettings,
+ $seleniumBrowsers,
+ $seleniumTestSuites,
+ $this->tempFileName );
+
$this->assertEquals($seleniumSettings, $expectedSettings,
"The selenium settings for the following test configuration was
not retrieved correctly" . $sampleConfig
);
Copied: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php (from rev
73501, trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php)
===================================================================
--- trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php
(rev 0)
+++ trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php 2010-09-22
21:23:21 UTC (rev 73574)
@@ -0,0 +1,48 @@
+<?php
+if ( !defined( 'SELENIUMTEST' ) ) {
+ die( 1 );
+}
+
+class SeleniumConfig {
+
+ /*
+ * Retreives the Selenium configuration values from an ini file.
+ * See sample config file in selenium_settings.ini.sample
+ *
+ */
+ public static function getSeleniumSettings ( &$seleniumSettings,
+ &$seleniumBrowsers,
+ &$seleniumTestSuites,
+ $seleniumConfigFile = null ) {
+ if ( strlen( $seleniumConfigFile ) == 0 ) {
+ global $wgSeleniumConfigFile;
+ if ( isset( $wgSeleniumConfigFile ) )
$seleniumConfigFile = $wgSeleniumConfigFile ;
+ }
+
+ if ( strlen( $seleniumConfigFile ) == 0 || !file_exists(
$seleniumConfigFile ) ) {
+ throw new MWException( "Unable to read local Selenium
Settings from " . $seleniumConfigFile . "\n" );
+ }
+
+ $configArray = parse_ini_file($seleniumConfigFile, true);
+ if ( array_key_exists( 'SeleniumSettings', $configArray) ) {
+ wfSuppressWarnings();
+ //we may need to change how this is set. But for now
leave it in the ini file
+ $seleniumBrowsers =
$configArray['SeleniumSettings']['browsers'];
+
+ $seleniumSettings['host'] =
$configArray['SeleniumSettings']['host'];
+ $seleniumSettings['port'] =
$configArray['SeleniumSettings']['port'];
+ $seleniumSettings['wikiUrl'] =
$configArray['SeleniumSettings']['wikiUrl'];
+ $seleniumSettings['username'] =
$configArray['SeleniumSettings']['username'];
+ $seleniumSettings['userPassword'] =
$configArray['SeleniumSettings']['userPassword'];
+ $seleniumSettings['testBrowser'] =
$configArray['SeleniumSettings']['testBrowser'];
+ wfRestoreWarnings();
+ }
+ if ( array_key_exists( 'SeleniumTests', $configArray) ) {
+ wfSuppressWarnings();
+ $seleniumTestSuites =
$configArray['SeleniumTests']['testSuite'];
+ wfRestoreWarnings();
+ }
+ return true;
+ }
+
+}
Deleted: trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php
===================================================================
--- trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php
2010-09-22 21:15:58 UTC (rev 73573)
+++ trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php
2010-09-22 21:23:21 UTC (rev 73574)
@@ -1,46 +0,0 @@
-<?php
-
-class SeleniumTestConfig {
-
- /*
- * Retreives the Selenium configuration values from an ini file.
- * See sample config file in selenium_settings.ini.sample
- *
- */
- public static function getSeleniumSettings ( &$seleniumSettings,
-
&$seleniumBrowsers,
-
&$seleniumTestSuites,
-
$seleniumConfigFile = null ) {
- if ( $seleniumConfigFile == null ) {
- global $wgSeleniumConfigFile;
- $seleniumConfigFile = ( isset( $wgSeleniumConfigFile )
) ?
-
$wgSeleniumConfigFile : dirname( __FILE__ ) . "/../../../selenium_settings.ini";
- }
-
- if ( !file_exists( $seleniumConfigFile ) ) {
- throw new MWException( "Unable to read local Selenium
Settings from " . $seleniumConfigFile . "\n" );
- }
-
- $configArray = parse_ini_file($seleniumConfigFile, true);
- if ( array_key_exists( 'SeleniumSettings', $configArray) ) {
- wfSuppressWarnings();
- //we may need to change how this is set. But for now
leave it in the ini file
- $seleniumBrowsers =
$configArray['SeleniumSettings']['browsers'];
-
- $seleniumSettings['host'] =
$configArray['SeleniumSettings']['host'];
- $seleniumSettings['port'] =
$configArray['SeleniumSettings']['port'];
- $seleniumSettings['wikiUrl'] =
$configArray['SeleniumSettings']['wikiUrl'];
- $seleniumSettings['username'] =
$configArray['SeleniumSettings']['username'];
- $seleniumSettings['userPassword'] =
$configArray['SeleniumSettings']['userPassword'];
- $seleniumSettings['testBrowser'] =
$configArray['SeleniumSettings']['testBrowser'];
- wfRestoreWarnings();
- }
- if ( array_key_exists( 'SeleniumTests', $configArray) ) {
- wfSuppressWarnings();
- $seleniumTestSuites =
$configArray['SeleniumTests']['testSuite'];
- wfRestoreWarnings();
- }
- return true;
- }
-
-}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs