6 * @copyright Copyright © Wikimedia Deuschland, 2009
7 * @author Hallo Welt! Medienwerkstatt GmbH
8 * @author Markus Glaser, Dan Nessett
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 define( 'SELENIUMTEST', true );
28 require_once( dirname( dirname( __FILE__
) )."/Maintenance.php" );
30 class SeleniumTester
extends Maintenance
{
31 public function __construct() {
32 parent
::__construct();
34 $this->addOption( 'port', 'Port used by selenium server' );
35 $this->addOption( 'host', 'Host selenium server' );
36 $this->addOption( 'browser', 'The browser he used during testing' );
37 $this->addOption( 'url', 'The Mediawiki installation to point to.' );
38 $this->addOption( 'list-browsers', 'List the available browsers.' );
40 $this->deleteOption( 'dbpass' );
41 $this->deleteOption( 'dbuser' );
42 $this->deleteOption( 'globals' );
43 $this->deleteOption( 'wiki' );
46 public function listBrowsers() {
47 global $wgSeleniumTestsBrowsers;
49 $desc = "Available browsers:\n";
50 foreach ($wgSeleniumTestsBrowsers as $k => $v) {
51 $desc .= " $k => $v\n";
57 protected function runTests() {
58 global $wgSeleniumLogger, $wgSeleniumTestSuites;
60 SeleniumLoader
::load();
61 $result = new PHPUnit_Framework_TestResult
;
62 $wgSeleniumLogger = new SeleniumTestConsoleLogger
;
63 $result->addListener( new SeleniumTestListener( $wgSeleniumLogger ) );
65 foreach ( $wgSeleniumTestSuites as $testSuiteName ) {
66 $suite = new $testSuiteName;
69 $suite->run( $result );
70 } catch ( Testing_Selenium_Exception
$e ) {
71 throw new MWException( $e->getMessage() );
76 public function execute() {
77 global $wgSeleniumServerPort, $wgSeleniumTestsSeleniumHost,
78 $wgSeleniumTestsWikiUrl, $wgServer, $wgScriptPath;
80 if( $this->hasOption( 'list-browsers' ) ) {
81 $this->listBrowsers();
85 $wgSeleniumServerPort = $this->getOption( 'port', 4444 );
86 $wgSeleniumTestsSeleniumHost = $this->getOption( 'host', 'localhost' );
87 $wgSeleniumTestsWikiUrl = $this->getOption( 'test-url', $wgServer . $wgScriptPath );
88 $wgSeleniumTestsUseBrowser = $this->getOption( 'browser', 'firefox' );
94 $maintClass = "SeleniumTester";
96 require_once( DO_MAINTENANCE
);