r73500 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73499‎ | r73500 | r73501 >
Date:00:16, 22 September 2010
Author:pdhanda
Status:ok (Comments)
Tags:
Comment:
RunSeleniumTests.php: Cleaned up a few options that this script takes. Settings are now through a file passed into seleniumConfig or via a hook SeleniumSettings. Reasonable default values when some value is not found.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/maintenance/tests/RunSeleniumTests.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php (added) (history)
  • /trunk/phase3/maintenance/tests/selenium/Selenium.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php (added) (history)
  • /trunk/phase3/maintenance/tests/selenium/SeleniumTestListener.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/SeleniumTestSuite.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/SimpleSeleniumTestCase.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/SimpleSeleniumTestSuite.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.sample (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/RunSeleniumTests.php
@@ -35,11 +35,14 @@
3636
3737 public function __construct() {
3838 parent::__construct();
39 -
40 - $this->addOption( 'port', 'Port used by selenium server' );
41 - $this->addOption( 'host', 'Host selenium server' );
42 - $this->addOption( 'browser', 'The browser he used during testing' );
43 - $this->addOption( 'url', 'The Mediawiki installation to point to.' );
 39+ $this->mDescription = "Selenium Test Runner. For documentation, visit http://www.mediawiki.org/wiki/SeleniumFramework";
 40+ $this->addOption( 'port', 'Port used by selenium server. Default: 4444' );
 41+ $this->addOption( 'host', 'Host selenium server. Default: $wgServer . $wgScriptPath' );
 42+ $this->addOption( 'testBrowser', 'The browser he used during testing. Default: firefox' );
 43+ $this->addOption( 'wikiUrl', 'The Mediawiki installation to point to. Default: http://localhost' );
 44+ $this->addOption( 'username', 'The login username for sunning tests. Default: empty' );
 45+ $this->addOption( 'userPassword', 'The login password for running tests. Default: empty' );
 46+ $this->addOption( 'seleniumConfig', 'Location of the selenium config file. Default: empty' );
4447 $this->addOption( 'list-browsers', 'List the available browsers.' );
4548 $this->addOption( 'verbose', 'Be noisier.' );
4649
@@ -52,46 +55,76 @@
5356 public function listBrowsers() {
5457 $desc = "Available browsers:\n";
5558
56 - $sel = new Selenium;
57 - foreach ($sel->setupBrowsers() as $k => $v) {
 59+ foreach ($this->selenium->getAvailableBrowsers() as $k => $v) {
5860 $desc .= " $k => $v\n";
5961 }
6062
6163 echo $desc;
6264 }
6365
64 - protected function getTestSuites() {
65 - return array( 'SimpleSeleniumTestSuite' );
66 - }
67 -
68 - protected function runTests( ) {
 66+ protected function runTests( $seleniumTestSuites = array() ) {
6967 $result = new PHPUnit_Framework_TestResult;
7068 $result->addListener( new SeleniumTestListener( $this->selenium->getLogger() ) );
71 -
72 - foreach ( $this->getTestSuites() as $testSuiteName ) {
73 - $suite = new $testSuiteName;
 69+
 70+ foreach ( $seleniumTestSuites as $testSuiteName => $testSuiteFile ) {
 71+ require( $testSuiteFile );
 72+ $suite = new $testSuiteName();
7473 $suite->addTests();
 74+
7575 try {
7676 $suite->run( $result );
7777 } catch ( Testing_Selenium_Exception $e ) {
 78+ $suite->tearDown();
7879 throw new MWException( $e->getMessage() );
7980 }
8081 }
8182 }
8283
8384 public function execute() {
84 - global $wgServer, $wgScriptPath;
 85+ global $wgServer, $wgScriptPath, $wgHooks;
 86+
 87+ $seleniumSettings;
 88+ $seleniumBrowsers;
 89+ $seleniumTestSuites;
8590
86 - /**
87 - * @todo Add an alternative where settings are read from an INI file.
88 - */
 91+ $configFile = $this->getOption( 'seleniumConfig', '' );
 92+ if ( strlen( $configFile ) > 0 ) {
 93+ $this->output("Using Selenium Configuration file: " . $configFile . "\n");
 94+ SeleniumTestConfig::getSeleniumSettings( &$seleniumSettings,
 95+ &$seleniumBrowsers,
 96+ &$seleniumTestSuites,
 97+ $configFile );
 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
 103+ );
 104+ } else {
 105+ $this->output("Using 'SeleniumSettings' hook for configuration.\n");
 106+ wfRunHooks('SeleniumSettings', array( &$seleniumSettings,
 107+ &$seleniumBrowsers,
 108+ &$seleniumTestSuites ) );
 109+ }
 110+
 111+
 112+ //set reasonable defaults if we did not find the settings
 113+ if ( !isset( $seleniumBrowsers ) ) $seleniumBrowsers = array ('firefox' => '*firefox');
 114+ if ( !isset( $seleniumSettings['host'] ) ) $seleniumSettings['host'] = $wgServer . $wgScriptPath;
 115+ if ( !isset( $seleniumSettings['port'] ) ) $seleniumSettings['port'] = '4444';
 116+ if ( !isset( $seleniumSettings['wikiUrl'] ) ) $seleniumSettings['wikiUrl'] = 'http://localhost';
 117+ if ( !isset( $seleniumSettings['username'] ) ) $seleniumSettings['username'] = '';
 118+ if ( !isset( $seleniumSettings['userPassword'] ) ) $seleniumSettings['userPassword'] = '';
 119+ if ( !isset( $seleniumSettings['testBrowser'] ) ) $seleniumSettings['testBrowser'] = 'firefox';
 120+
89121 $this->selenium = new Selenium( );
90 - $this->selenium->setUrl( $this->getOption( 'url', $wgServer . $wgScriptPath ) );
91 - $this->selenium->setBrowser( $this->getOption( 'browser', 'firefox' ) );
92 - $this->selenium->setPort( $this->getOption( 'port', 4444 ) );
93 - $this->selenium->setHost( $this->getOption( 'host', 'localhost' ) );
94 - $this->selenium->setUser( $this->getOption( 'user', 'WikiSysop' ) );
95 - $this->selenium->setPass( $this->getOption( 'pass', 'Password' ) );
 122+ $this->selenium->setAvailableBrowsers( $seleniumBrowsers );
 123+ $this->selenium->setUrl( $this->getOption( 'wikiUrl', $seleniumSettings['wikiUrl'] ) );
 124+ $this->selenium->setBrowser( $this->getOption( 'testBrowser', $seleniumSettings['testBrowser'] ) );
 125+ $this->selenium->setPort( $this->getOption( 'port', $seleniumSettings['port'] ) );
 126+ $this->selenium->setHost( $this->getOption( 'host', $seleniumSettings['host'] ) );
 127+ $this->selenium->setUser( $this->getOption( 'username', $seleniumSettings['username'] ) );
 128+ $this->selenium->setPass( $this->getOption( 'userPassword', $seleniumSettings['userPassword'] ) );
96129 $this->selenium->setVerbose( $this->hasOption( 'verbose' ) );
97130
98131 if( $this->hasOption( 'list-browsers' ) ) {
@@ -102,7 +135,7 @@
103136 $logger = new SeleniumTestConsoleLogger;
104137 $this->selenium->setLogger( $logger );
105138
106 - $this->runTests( );
 139+ $this->runTests( $seleniumTestSuites );
107140 }
108141 }
109142
Index: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.sample
@@ -0,0 +1,17 @@
 2+[SeleniumSettings]
 3+
 4+browsers[firefox] = "*firefox"
 5+browsers[iexplorer] = "*iexploreproxy"
 6+browsers[chrome] = "*chrome"
 7+host = "localhost"
 8+port = "4444"
 9+wikiUrl = "http://localhost/deployment"
 10+username = "wikiuser"
 11+userPassword = "wikipass"
 12+testBrowser = "firefox"
 13+
 14+[SeleniumTests]
 15+
 16+testSuite[SimpleSeleniumTestSuite] = "maintenance/tests/selenium/SimpleSeleniumTestSuite.php"
 17+testSuite[PagedTiffHandlerSeleniumTestSuite] = "extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestSuite.php"
 18+
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestSuite.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -class SeleniumTestSuite extends PHPUnit_Framework_TestSuite {
 4+abstract class SeleniumTestSuite extends PHPUnit_Framework_TestSuite {
55 private $selenium;
66 private $isSetUp = false;
77
@@ -9,6 +9,8 @@
1010 const RESULT_OK = 2;
1111 const RESULT_ERROR = 3;
1212
 13+ public abstract function addTests();
 14+
1315 public function setUp() {
1416 // Hack because because PHPUnit version 3.0.6 which is on prototype does not
1517 // run setUp as part of TestSuite::run
@@ -18,11 +20,12 @@
1921 $this->isSetUp = true;
2022 $this->selenium = Selenium::getInstance();
2123 $this->selenium->start();
 24+ //$this->selenium->open( $this->selenium->getUrl() . '/index.php?setupTestSuite=' . $this->getName() );
2225 $this->login();
23 - // $this->loadPage( 'Testpage', 'edit' );
2426 }
2527
2628 public function tearDown() {
 29+ //$this->selenium->open( $this->selenium->getUrl() . '/index.php?clearTestSuite=' . $this->getName() );
2730 $this->selenium->stop();
2831 }
2932
Index: trunk/phase3/maintenance/tests/selenium/Selenium.php
@@ -8,6 +8,7 @@
99
1010 class Selenium {
1111 protected static $_instance = null;
 12+
1213 public $isStarted = false;
1314 public $tester;
1415
@@ -56,27 +57,15 @@
5758 $this->isStarted = false;
5859 }
5960
60 - protected function setupBrowsers() {
61 - /**
62 - * @todo This needs to be replaced with something not hard
63 - * coded. This would be entries in a .ini file or
64 - * screen-scraping
65 - * http://grid.tesla.usability.wikimedia.org:4444/console for
66 - * example.
67 - */
68 - return array(
69 - 'firefox' => 'Firefox 3.5 on Linux',
70 - 'iexplorer' => '*iexploreproxy',
71 - 'chrome' => '*googlechrome',
72 - );
73 - }
74 -
7561 public function login() {
 62+ if ( strlen( $this->user ) == 0 ) {
 63+ return;
 64+ }
7665 $this->open( self::$url . '/index.php?title=Special:Userlogin' );
7766 $this->type( 'wpName1', $this->user );
7867 $this->type( 'wpPassword1', $this->pass );
7968 $this->click( "//input[@id='wpLoginAttempt']" );
80 - $this->waitForPageToLoad( 5000 );
 69+ $this->waitForPageToLoad( 10000 );
8170
8271 // after login we redirect to the main page. So check whether the "Prefernces" top menu item exists
8372 $value = $this->isElementPresent( "//li[@id='pt-preferences']" );
@@ -138,17 +127,22 @@
139128 public function setVerbose( $verbose ) {
140129 $this->verbose = $verbose;
141130 }
 131+
 132+ public function setAvailableBrowsers( $availableBrowsers ) {
 133+ $this->browsers = $availableBrowsers;
 134+ }
142135
143136 public function setBrowser( $b ) {
144 - $browsers = $this->setupBrowsers();
145 -
146 -
147 - if ( !isset( $browsers[$b] ) ) {
 137+ if ( !isset( $this->browsers[$b] ) ) {
148138 throw new MWException( "Invalid Browser: $b.\n" );
149139 }
150140
151 - $this->browser = $browsers[$b];
 141+ $this->browser = $this->browsers[$b];
152142 }
 143+
 144+ public function getAvailableBrowsers() {
 145+ return $this->browsers;
 146+ }
153147
154148 public function __call( $name, $args ) {
155149 $t = call_user_func_array( array( $this->tester, $name ), $args );
Index: trunk/phase3/maintenance/tests/selenium/SimpleSeleniumTestSuite.php
@@ -1,15 +1,13 @@
22 <?php
3 -
4 -require_once(dirname( __FILE__ ) . '/SimpleSeleniumTestCase.php');
53
64 class SimpleSeleniumTestSuite extends SeleniumTestSuite
75 {
8 - public function __construct( $name = 'Basic selenium test suite') {
9 - parent::__construct( $name );
10 - }
11 -
126 public function addTests() {
13 - $test = new SimpleSeleniumTestCase();
14 - parent::addTest( $test );
 7+ $testFiles = array(
 8+ 'maintenance/tests/selenium/SimpleSeleniumTestCase.php'
 9+ );
 10+ parent::addTestFiles( $testFiles );
1511 }
 12+
 13+
1614 }
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestConfig.php
@@ -0,0 +1,46 @@
 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/SeleniumTestListener.php
@@ -49,13 +49,16 @@
5050 public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
5151 $this->logger->write( 'Testsuite ' . $suite->getName() . ' started.' );
5252 $this->tests_ok = 0;
 53+ $this->tests_failed = 0;
5354 }
5455
5556 public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
56 - $this->logger->write(
57 - 'Testsuite ' . $suite->getName() . ' ended. OK: ' .
58 - $this->tests_ok . ' Failed: ' . $this->tests_failed
59 - );
 57+ $this->logger->write('Testsuite ' . $suite->getName() . ' ended.' );
 58+ if ( $this->tests_ok > 0 || $this->tests_failed > 0 ) {
 59+ $this->logger->write( ' OK: ' . $this->tests_ok . ' Failed: ' . $this->tests_failed );
 60+ }
 61+ $this->tests_ok = 0;
 62+ $this->tests_failed = 0;
6063 }
6164
6265 public function statusMessage( $message ) {
Index: trunk/phase3/maintenance/tests/selenium/SimpleSeleniumTestCase.php
@@ -2,13 +2,9 @@
33
44 class SimpleSeleniumTestCase extends SeleniumTestCase
55 {
6 - public function __construct( $name = 'Basic selenium test') {
7 - parent::__construct( $name );
8 - }
9 -
10 - public function runTest()
 6+ public function testBasic()
117 {
12 - $this->open( Selenium::getBaseUrl() .
 8+ $this->open( $this->getUrl() .
139 '/index.php?title=Selenium&action=edit' );
1410 $this->type( "wpTextbox1", "This is a basic test" );
1511 $this->click( "wpPreview" );
@@ -20,5 +16,17 @@
2117 $this->assertEquals( $correct, true );
2218
2319 }
 20+
 21+ /*
 22+ * Needs the following in your LocalConfig or an alternative method of configuration (coming soon)
 23+ * require_once( "$IP/extensions/UsabilityInitiative/Vector/Vector.php" );
 24+ * $wgDefaultSkin='vector';
 25+ */
 26+ public function testGlobalVariable1()
 27+ {
 28+ $this->open( $this->getUrl() . '/index.php?&action=purge' );
 29+ $bodyClass = $this->getAttribute( "//body/@class" );
 30+ $this-> assertContains('skin-vector', $bodyClass, 'Vector skin not set');
 31+ }
2432
2533 }
Index: trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php
@@ -0,0 +1,174 @@
 2+<?php
 3+
 4+class SeleniumConfigurationTest extends PHPUnit_Framework_TestCase {
 5+
 6+ /*
 7+ * The file where the test temporarity stores the selenium config.
 8+ * This should be cleaned up as part of teardown.
 9+ */
 10+ private $tempFileName;
 11+
 12+ /*
 13+ * String containing the a sample selenium settings
 14+ */
 15+ private $testConfig0 =
 16+'
 17+[SeleniumSettings]
 18+browsers[firefox] = "*firefox"
 19+browsers[iexplorer] = "*iexploreproxy"
 20+browsers[chrome] = "*chrome"
 21+host = "localhost"
 22+port = "foobarr"
 23+wikiUrl = "http://localhost/deployment"
 24+username = "xxxxxxx"
 25+userPassword = ""
 26+testBrowser = "chrome"
 27+
 28+[SeleniumTests]
 29+testSuite[SimpleSeleniumTestSuite] = "maintenance/tests/selenium/SimpleSeleniumTestSuite.php"
 30+testSuite[TestSuiteName] = "testSuitePath"
 31+';
 32+ /*
 33+ * Array of expected browsers from $testConfig0
 34+ */
 35+ private $testBrowsers0 = array( 'firefox' => '*firefox',
 36+ 'iexplorer' => '*iexploreproxy',
 37+ 'chrome' => '*chrome'
 38+ );
 39+ /*
 40+ * Array of expected selenium settings from $testConfig0
 41+ */
 42+ private $testSettings0 = array(
 43+ 'host' => 'localhost',
 44+ 'port' => 'foobarr',
 45+ 'wikiUrl' => 'http://localhost/deployment',
 46+ 'username' => 'xxxxxxx',
 47+ 'userPassword' => '',
 48+ 'testBrowser' => 'chrome'
 49+ );
 50+ /*
 51+ * Array of expected testSuites from $testConfig0
 52+ */
 53+ private $testSuites0 = array(
 54+ 'SimpleSeleniumTestSuite' => 'maintenance/tests/selenium/SimpleSeleniumTestSuite.php',
 55+ 'TestSuiteName' => 'testSuitePath'
 56+ );
 57+
 58+
 59+ /*
 60+ * Another sample selenium settings file contents
 61+ */
 62+ private $testConfig1 =
 63+'
 64+[SeleniumSettings]
 65+host = "localhost"
 66+testBrowser = "firefox"
 67+';
 68+ /*
 69+ * Expected browsers from $testConfig1
 70+ */
 71+ private $testBrowsers1 = null;
 72+ /*
 73+ * Expected selenium settings from $testConfig1
 74+ */
 75+ private $testSettings1 = array(
 76+ 'host' => 'localhost',
 77+ 'port' => null,
 78+ 'wikiUrl' => null,
 79+ 'username' => null,
 80+ 'userPassword' => null,
 81+ 'testBrowser' => 'firefox'
 82+ );
 83+ /*
 84+ * Expected test suites from $testConfig1
 85+ */
 86+ private $testSuites1 = null;
 87+
 88+
 89+ /*
 90+ * Clean up the temporary file used to sore the selenium settings.
 91+ */
 92+ public function tearDown() {
 93+ if ( strlen( $this->tempFileName ) > 0 ) {
 94+ unlink( $this->tempFileName );
 95+ unset( $this->tempFileName );
 96+ }
 97+ parent::tearDown();
 98+ }
 99+
 100+ /**
 101+ * @expectedException MWException
 102+ * @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+ */
 106+ public function testErrorOnMissingConfigFile() {
 107+ $seleniumSettings;
 108+ $seleniumBrowsers;
 109+ $seleniumTestSuites;
 110+
 111+ SeleniumTestConfig::getSeleniumSettings(&$seleniumSettings,
 112+ &$seleniumBrowsers,
 113+ &$seleniumTestSuites,
 114+ "Some_fake_settings_file.ini" );
 115+ }
 116+
 117+ /**
 118+ * @group SeleniumFramework
 119+ * @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+ */
 123+ public function testgetSeleniumSettings($sampleConfig, $expectedSettings, $expectedBrowsers, $expectedSuites ) {
 124+ //print "SAMPLE_CONFIG " . $sampleConfig . "\n\n";
 125+ $this->writeToTempFile( $sampleConfig );
 126+ $seleniumSettings;
 127+ $seleniumBrowsers;
 128+ $seleniumTestSuites;
 129+
 130+ SeleniumTestConfig::getSeleniumSettings(&$seleniumSettings,
 131+ &$seleniumBrowsers,
 132+ &$seleniumTestSuites,
 133+ $this->tempFileName );
 134+
 135+
 136+ $this->assertEquals($seleniumSettings, $expectedSettings,
 137+ "The selenium settings for the following test configuration was not retrieved correctly" . $sampleConfig
 138+ );
 139+ $this->assertEquals($seleniumBrowsers, $expectedBrowsers,
 140+ "The available browsers for the following test configuration was not retrieved correctly" . $sampleConfig
 141+ );
 142+ $this->assertEquals($seleniumTestSuites, $expectedSuites,
 143+ "The test suites for the following test configuration was not retrieved correctly" . $sampleConfig
 144+ );
 145+
 146+
 147+ }
 148+
 149+ /*
 150+ * create a temp file and write text to it.
 151+ * @param $testToWrite the text to write to the temp file
 152+ */
 153+ private function writeToTempFile($textToWrite) {
 154+ $this->tempFileName = tempnam(sys_get_temp_dir(), 'test_settings.');
 155+ $tempFile = fopen( $this->tempFileName, "w" );
 156+ fwrite($tempFile , $textToWrite);
 157+ fclose($tempFile);
 158+ }
 159+
 160+ /*
 161+ * Returns an array containing:
 162+ * The contents of the selenium cingiguration ini file
 163+ * The expected selenium configuration array that getSeleniumSettings should return
 164+ * The expected available browsers array that getSeleniumSettings should return
 165+ * The expected test suites arrya that getSeleniumSettings should return
 166+ */
 167+ public function sampleConfigs() {
 168+ return array(
 169+ array($this->testConfig0, $this->testSettings0, $this->testBrowsers0, $this->testSuites0 ),
 170+ array($this->testConfig1, $this->testSettings1, $this->testBrowsers1, $this->testSuites1 )
 171+ );
 172+ }
 173+
 174+
 175+}
\ No newline at end of file
Index: trunk/phase3/includes/AutoLoader.php
@@ -633,7 +633,6 @@
634634 'SpecialRecentChanges' => 'includes/specials/SpecialRecentchanges.php',
635635 'SpecialRecentchangeslinked' => 'includes/specials/SpecialRecentchangeslinked.php',
636636 'SpecialSearch' => 'includes/specials/SpecialSearch.php',
637 - 'SpecialSelenium' => 'includes/specials/SpecialSelenium.php',
638637 'SpecialSpecialpages' => 'includes/specials/SpecialSpecialpages.php',
639638 'SpecialStatistics' => 'includes/specials/SpecialStatistics.php',
640639 'SpecialTags' => 'includes/specials/SpecialTags.php',
@@ -705,7 +704,6 @@
706705 'UserDupes' => 'maintenance/userDupes.inc',
707706
708707 # maintenance/tests/selenium
709 - 'SimpleSeleniumTestSuite' => 'maintenance/tests/selenium/SimpleSeleniumTestSuite.php',
710708 'Selenium' => 'maintenance/tests/selenium/Selenium.php',
711709 'SeleniumLoader' => 'maintenance/tests/selenium/SeleniumLoader.php',
712710 'SeleniumTestCase' => 'maintenance/tests/selenium/SeleniumTestCase.php',
@@ -713,6 +711,7 @@
714712 'SeleniumTestHTMLLogger' => 'maintenance/tests/selenium/SeleniumTestHTMLLogger.php',
715713 'SeleniumTestListener' => 'maintenance/tests/selenium/SeleniumTestListener.php',
716714 'SeleniumTestSuite' => 'maintenance/tests/selenium/SeleniumTestSuite.php',
 715+ 'SeleniumTestConfig' => 'maintenance/tests/selenium/SeleniumTestConfig.php',
717716
718717 # maintenance/language
719718 'csvStatsOutput' => 'maintenance/language/StatOutputs.php',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -5117,6 +5117,13 @@
51185118 );
51195119
51205120 /**
 5121+ * Allows running of selenium tests via maintenance/tests/RunSeleniumTests.php
 5122+ */
 5123+$wgEnableSelenium = false;
 5124+
 5125+
 5126+
 5127+/**
51215128 * For really cool vim folding this needs to be at the end:
51225129 * vim: foldmarker=@{,@} foldmethod=marker
51235130 * @}

Follow-up revisions

RevisionCommit summaryAuthorDate
r73574Followup to r73500. SeleniumTestConfig renamed to SeleniumConfig. Make sure S...pdhanda21:23, 22 September 2010

Comments

#Comment by Pdhanda (talk | contribs)   00:21, 22 September 2010

I accidentally truncated my commit message: RunSeleniumTests.php: Cleaned up a few options that this script takes. Settings are now through a file passed into seleniumConfig or via a hook SeleniumSettings. Reasonable default values when some value is not found. selenium_settings.ini.sample: Sample selenium configuration file. SeleniumTestSuite.php, SimpleSeleniumTestSuite.php: Made addTests an abstract an abstract function. Selenium.php: It is possible to run tests without login. New function setAvailableBrowsers so that the test runner can decide how to set those. SeleniumTestListener: Don't try to log results if no tests we run. SimpleSeleniumTestCase.php: Cleanup. Added a additional test that depends on a global config. Breaks for now without changes to LocalSettings. SeleniumTestConfig: For now only a hook that resturns the Selenium test settings. This is read from an ini file that can be passed in or defaults to selenium_setting.ini SeleniumConfigurationTest.php: Unit test for SeleniumTestConfig::getSeleniumSettings AutoLoader.php: Removed SpecialSelenium and SimpleSeleniumTestSuite. Added SeleniumTestConfig. DefaultSettings.php : global $wgEnableSelenium set to false.

#Comment by Nikerabbit (talk | contribs)   05:35, 22 September 2010

The indentation has mixed tabs and spaces in trunk/phase3/maintenance/tests/phpunit/includes/SeleniumConfigurationTest.php. Also, tabs can also be used at line start, or it gets ugly as you can see if you watch the diff in this page.

+SeleniumTestConfig::getSeleniumSettings( &$seleniumSettings, 
+ &$seleniumBrowsers, 
+ &$seleniumTestSuites,
+ $configFile );

I think that those &s are going to produce deprecation warnings in new versions of PHP. References should only be marked at the function definition.

#Comment by Platonides (talk | contribs)   16:20, 22 September 2010

$wgSeleniumConfigFile is not in DefaultSettings so you can do an isset on it: + $seleniumConfigFile = ( isset( $wgSeleniumConfigFile ) ) ? + $wgSeleniumConfigFile : dirname( __FILE__ ) . "/../../../selenium_settings.ini";

which is a register_globals vulnerability for injecting your own configuration (if it were accessed via the web instead of a maintenance script).


Also, I would remove the word Test frome these filenames. It makes it look as a test config for Selenium instead of a Config for Selenium Tests

#Comment by Pdhanda (talk | contribs)   16:59, 20 October 2010

Added $wgSeleniumConfigFile to DefaultSettings and a test to make sure SELENIUMTEST is set. Still need to document new variables.

Status & tagging log