bae7234c45e53ed2c3a7248233843de40cdedce6
[lhc/web/wiklou.git] / maintenance / tests / RunSeleniumTests.php
1 <?php
2 /**
3 * Copyright (C) Wikimedia Deuschland, 2009
4 * Authors Hallo Welt! Medienwerkstatt GmbH
5 * Authors Markus Glaser
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 *
22 */
23
24 define( "MEDIAWIKI", true );
25 define( "SELENIUMTEST", true);
26
27 //command line only
28 $wgSeleniumTestsRunMode = 'cli';
29 if( $wgSeleniumTestsRunMode == 'cli' && php_sapi_name() != 'cli' ) {
30 echo 'Must be run from the command line.';
31 die( -1 );
32 }
33 //include path and installation instructions
34
35 //URL: http://localhost/tests/RunSeleniumTests.php
36 //set_include_path(get_include_path() . PATH_SEPARATOR . './PEAR/');
37
38 // Hostname of selenium server
39 $wgSeleniumTestsSeleniumHost = "http://localhost";
40
41 // URL of the wiki to be tested.
42 $wgSeleniumTestsWikiUrl = 'http://localhost';
43
44 // Wiki login. Used by Selenium to log onto the wiki
45 $wgSeleniumTestsWikiUser = "WikiSysop";
46 $wgSeleniumTestsWikiPassword = "password";
47
48 // Common browsers on Windows platform
49 // Use the *chrome handler in order to be able to test file uploads
50 // further solution suggestions: http://www.brokenbuild.com/blog/2007/06/07/testing-file-uploads-with-selenium-rc-and-firefoxor-reducing-javascript-security-in-firefox-for-fun-and-profit/
51 //$wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
52 $wgSeleniumTestsBrowsers['firefox'] = '*chrome c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe';
53 $wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy';
54
55 // Actually, use this browser
56 $wgSeleniumTestsUseBrowser = 'firefox';
57
58 // requires PHPUnit 3.4
59 require_once 'Testing/Selenium.php';
60 require_once 'PHPUnit/Framework.php';
61 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
62
63 // include uiTestsuite
64 require_once 'selenium/SeleniumTestHTMLLogger.php';
65 require_once 'selenium/SeleniumTestConsoleLogger.php';
66 require_once 'selenium/SeleniumTestListener.php';
67 require_once 'selenium/Selenium.php';
68 require_once 'selenium/SeleniumTestSuite.php';
69 require_once 'selenium/SeleniumTestCase.php';
70
71 $result = new PHPUnit_Framework_TestResult;
72 switch ($wgSeleniumTestsRunMode) {
73 case 'html' : $logger = new SeleniumTestHTMLLogger; break;
74 case 'cli' : $logger = new SeleniumTestConsoleLogger; break;
75 }
76 $result->addListener(new SeleniumTestListener($logger));
77
78
79 $wgSeleniumTestSuites = array();
80
81 // Todo: include automatically
82 #include_once '<your tests>';
83
84 // Here, you can override standard setting
85 if (file_exists('LocalSeleniumSettings.php'))
86 {
87 include_once 'LocalSeleniumSettings.php';
88 }
89
90 // run tests
91 foreach ($wgSeleniumTestSuites as $suite)
92 $suite->run($result);
93 ?>