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