#!/usr/bin/php addOption( 'port', 'Port used by selenium server' ); $this->addOption( 'host', 'Host selenium server' ); $this->addOption( 'browser', 'The browser he used during testing' ); $this->addOption( 'url', 'The Mediawiki installation to point to.' ); $this->addOption( 'list-browsers', 'List the available browsers.' ); $this->addOption( 'verbose', 'Be noisier.' ); $this->deleteOption( 'dbpass' ); $this->deleteOption( 'dbuser' ); $this->deleteOption( 'globals' ); $this->deleteOption( 'wiki' ); } public function listBrowsers() { $desc = "Available browsers:\n"; $sel = new Selenium; foreach ($sel->setupBrowsers() as $k => $v) { $desc .= " $k => $v\n"; } echo $desc; } protected function getTestSuites() { return array( 'SimpleSeleniumTestSuite' ); } protected function runTests( ) { $result = new PHPUnit_Framework_TestResult; $result->addListener( new SeleniumTestListener( $this->selenium->getLogger() ) ); foreach ( $this->getTestSuites() as $testSuiteName ) { $suite = new $testSuiteName; $suite->addTests(); try { $suite->run( $result ); } catch ( Testing_Selenium_Exception $e ) { throw new MWException( $e->getMessage() ); } } } public function execute() { global $wgServer, $wgScriptPath; /** * @todo Add an alternative where settings are read from an INI file. */ $this->selenium = new Selenium( ); $this->selenium->setUrl( $this->getOption( 'url', $wgServer . $wgScriptPath ) ); $this->selenium->setBrowser( $this->getOption( 'browser', 'firefox' ) ); $this->selenium->setPort( $this->getOption( 'port', 4444 ) ); $this->selenium->setHost( $this->getOption( 'host', 'localhost' ) ); $this->selenium->setUser( $this->getOption( 'user', 'WikiSysop' ) ); $this->selenium->setPass( $this->getOption( 'pass', 'Password' ) ); $this->selenium->setVerbose( $this->hasOption( 'verbose' ) ); if( $this->hasOption( 'list-browsers' ) ) { $this->listBrowsers(); exit(0); } $logger = new SeleniumTestConsoleLogger; $this->selenium->setLogger( $logger ); $this->runTests( ); } } $maintClass = "SeleniumTester"; require_once( DO_MAINTENANCE );