Index: trunk/phase3/maintenance/tests/RunSeleniumTests.php |
— | — | @@ -22,79 +22,33 @@ |
23 | 23 | * http://www.gnu.org/copyleft/gpl.html |
24 | 24 | */ |
25 | 25 | |
26 | | -define( 'MEDIAWIKI', true ); |
27 | 26 | define( 'SELENIUMTEST', true ); |
28 | 27 | |
29 | | -// Here, you can override standard setting |
30 | | -if ( file_exists( 'selenium/LocalSeleniumSettings.php' ) ) { |
31 | | - include_once 'selenium/LocalSeleniumSettings.php'; |
32 | | -} else { |
33 | | - echo "You must provide local settings in LocalSeleniumSettings.php\n"; |
34 | | - die( -1 ); |
35 | | -} |
36 | | - |
37 | | -// Command line only |
38 | | -if ( $wgSeleniumTestsRunMode == 'cli' && php_sapi_name() != 'cli' ) { |
39 | | - echo "Must be run from the command line.\n"; |
40 | | - die( -1 ); |
41 | | -} |
42 | | - |
43 | | -// Get command line parameters |
44 | | -if ( $wgSeleniumTestsRunMode == 'cli' ) { |
45 | | - require_once( dirname( __FILE__ ) . '/../commandLine.inc' ); |
46 | | - if ( isset( $options['help'] ) ) { |
47 | | - echo <<<ENDS |
| 28 | +require( dirname( __FILE__ ) . "/../commandLine.inc" ); |
| 29 | +if ( isset( $options['help'] ) ) { |
| 30 | + echo <<<ENDS |
48 | 31 | MediaWiki $wgVersion Selenium Framework tester |
49 | 32 | Usage: php RunSeleniumTests.php [options...] |
50 | 33 | Options: |
51 | | - --port=<TCP port> Port used by selenium server to accept commands |
52 | | - --help Show this help message |
| 34 | +--port=<TCP port> Port used by selenium server to accept commands |
| 35 | +--help Show this help message |
53 | 36 | ENDS; |
54 | | - exit( 0 ); |
55 | | - } |
| 37 | + exit( 1 ); |
| 38 | +} |
56 | 39 | |
57 | | - if ( isset( $options['port'] ) ) { |
58 | | - $wgSeleniumServerPort = (int) $options['port']; |
59 | | - } |
| 40 | +if ( isset( $options['port'] ) ) { |
| 41 | + $wgSeleniumServerPort = (int) $options['port']; |
60 | 42 | } |
61 | 43 | |
62 | | -// requires PHPUnit 3.4 |
63 | | -require_once 'Testing/Selenium.php'; |
64 | | -require_once 'PHPUnit/Framework.php'; |
65 | | -require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; |
| 44 | +SeleniumLoader::load(); |
66 | 45 | |
67 | | -// include seleniumTestsuite |
68 | | -require_once 'selenium/SeleniumTestHTMLLogger.php'; |
69 | | -require_once 'selenium/SeleniumTestConsoleLogger.php'; |
70 | | -require_once 'selenium/SeleniumTestListener.php'; |
71 | | -require_once 'selenium/Selenium.php'; |
72 | | -require_once 'selenium/SeleniumTestSuite.php'; |
73 | | -require_once 'selenium/SeleniumTestCase.php'; |
74 | | - |
75 | 46 | $result = new PHPUnit_Framework_TestResult; |
76 | | -switch ( $wgSeleniumTestsRunMode ) { |
77 | | - case 'html': |
78 | | - $logger = new SeleniumTestHTMLLogger; |
79 | | - break; |
80 | | - case 'cli': |
81 | | - $logger = new SeleniumTestConsoleLogger; |
82 | | - break; |
83 | | -} |
84 | | - |
| 47 | +$logger = new SeleniumTestConsoleLogger; |
85 | 48 | $result->addListener( new SeleniumTestListener( $logger ) ); |
86 | 49 | |
87 | | -$wgSeleniumTestSuites = array(); |
88 | | - |
89 | | -// include tests |
90 | | -// Todo: include automatically |
91 | | -if ( is_array( $wgSeleniumTestIncludes ) ) { |
92 | | - foreach ( $wgSeleniumTestIncludes as $include ) { |
93 | | - include_once $include; |
94 | | - } |
| 50 | +$suite = new SeleniumTestSuite; |
| 51 | +foreach ( $wgSeleniumTests as $testClass ) { |
| 52 | + $suite->addTest( new $testClass ); |
95 | 53 | } |
| 54 | +$suite->run( $result ); |
96 | 55 | |
97 | | -// run tests |
98 | | -foreach ( $wgSeleniumTestSuites as $suite ) { |
99 | | - $suite->run( $result ); |
100 | | -} |
101 | | - |
Index: trunk/phase3/maintenance/tests/selenium/LocalSeleniumSettings.php.sample |
— | — | @@ -1,51 +0,0 @@ |
2 | | -<?php |
3 | | -// This template file contains variables that should be localized. |
4 | | -// The line (specifying the location of the PHP/PEAR libraries) must be |
5 | | -// first. Moving it to a position later in the file will almost certainly |
6 | | -// cause an error. |
7 | | - |
8 | | -// In order to use this file, first copy it to LocalSeleniumSettings.php. |
9 | | -// Then edit the information to conform to the local environment. You |
10 | | -// will almost certainly have to uncomment the line set_include_path ... and |
11 | | -// change the string 'PEAR' to the path to your PEAR library, e.g., |
12 | | -// '/usr/share/php/PEAR' for a Debian based Linux system. |
13 | | -// The edited file must appear in the ../tests/selenium directory. |
14 | | - |
15 | | -// include path. Set 'PEAR" to '/path/to/PEAR/library' |
16 | | - |
17 | | -// URL: http://localhost/tests/RunSeleniumTests.php |
18 | | -#set_include_path( get_include_path() . PATH_SEPARATOR . 'PEAR' ); |
19 | | - |
20 | | -// Hostname of selenium server |
21 | | -$wgSeleniumTestsSeleniumHost = 'localhost'; |
22 | | - |
23 | | -// URL of the wiki to be tested. Consult web server configuration. |
24 | | -$wgSeleniumTestsWikiUrl = 'http://localhost'; |
25 | | - |
26 | | -// Port used by selenium server (optional - default is 4444) |
27 | | -$wgSeleniumServerPort = 4444; |
28 | | - |
29 | | -// Wiki login. Used by Selenium to log onto the wiki |
30 | | -$wgSeleniumTestsWikiUser = 'Wikisysop'; |
31 | | -$wgSeleniumTestsWikiPassword = 'password'; |
32 | | - |
33 | | -// Common browsers on Windows platform. Modify for other platforms or |
34 | | -// other Windows browsers |
35 | | -// Use the *chrome handler in order to be able to test file uploads |
36 | | -// 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/ |
37 | | -// $wgSeleniumTestsBrowsers['firefox'] = '*firefox c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe'; |
38 | | -$wgSeleniumTestsBrowsers['firefox'] = '*firefox /usr/bin/firefox'; |
39 | | -$wgSeleniumTestsBrowsers['iexplorer'] = '*iexploreproxy'; |
40 | | -$wgSeleniumTestsBrowsers['opera'] = '*chrome /usr/bin/opera'; |
41 | | - |
42 | | -// Actually, use this browser |
43 | | -$wgSeleniumTestsUseBrowser = 'firefox'; |
44 | | - |
45 | | -// Set command line mode |
46 | | -$wgSeleniumTestsRunMode = 'cli'; |
47 | | - |
48 | | -// List of tests to be included by default |
49 | | -$wgSeleniumTestIncludes = array( |
50 | | - 'selenium/SimpleSeleniumTest.php' |
51 | | -); |
52 | | -?> |
\ No newline at end of file |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestSuite.php |
— | — | @@ -1,17 +1,13 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { |
4 | | - echo "This script cannot be run standalone"; |
5 | | - exit( 1 ); |
6 | | -} |
7 | 3 | |
8 | | -// Do not add line break after test output |
9 | | -define( 'MW_TESTLOGGER_CONTINUE_LINE', 1 ); |
10 | | -define( 'MW_TESTLOGGER_RESULT_OK', 2 ); |
11 | | -define( 'MW_TESTLOGGER_RESULT_ERROR', 3 ); |
12 | | - |
13 | 4 | class SeleniumTestSuite extends PHPUnit_Framework_TestSuite { |
14 | 5 | private $selenium; |
15 | 6 | |
| 7 | + // Do not add line break after test output |
| 8 | + const CONTINUE_LINE = 1; |
| 9 | + const RESULT_OK = 2; |
| 10 | + const RESULT_ERROR = 3; |
| 11 | + |
16 | 12 | public function setUp() { |
17 | 13 | $this->selenium = Selenium::getInstance(); |
18 | 14 | $this->selenium->start(); |
Index: trunk/phase3/maintenance/tests/selenium/SimpleSeleniumTest.php |
— | — | @@ -1,31 +1,21 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) { |
5 | | - echo "This script cannot be run standalone"; |
6 | | - exit(1); |
7 | | -} |
8 | | - |
9 | | -// create test suite |
10 | | -$wgSeleniumTestSuites['SimpleSeleniumTest'] = new SeleniumTestSuite('Simple Selenium Test'); |
11 | | -$wgSeleniumTestSuites['SimpleSeleniumTest']->addTest(new SimpleSeleniumTest()); |
12 | | - |
13 | 4 | class SimpleSeleniumTest extends SeleniumTestCase |
14 | 5 | { |
15 | 6 | public $name = "Basic selenium test"; |
16 | 7 | |
17 | 8 | public function runTest() |
18 | 9 | { |
19 | | - global $wgSeleniumTestsWikiUrl; |
20 | | - $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Selenium&action=edit'); |
21 | | - $this->type("wpTextbox1", "This is a basic test"); |
22 | | - $this->click("wpPreview"); |
23 | | - $this->waitForPageToLoad(10000); |
| 10 | + $this->open( Selenium::getBaseUrl() . '/index.php?title=Selenium&action=edit' ); |
| 11 | + $this->type( "wpTextbox1", "This is a basic test" ); |
| 12 | + $this->click( "wpPreview" ); |
| 13 | + $this->waitForPageToLoad( 10000 ); |
24 | 14 | |
25 | 15 | // check result |
26 | | - $source = $this->getText("//div[@id='wikiPreview']/p"); |
27 | | - $correct = strstr($source, "This is a basic test"); |
28 | | - $this->assertEquals($correct, true); |
| 16 | + $source = $this->getText( "//div[@id='wikiPreview']/p" ); |
| 17 | + $correct = strstr( $source, "This is a basic test" ); |
| 18 | + $this->assertEquals( $correct, true ); |
29 | 19 | |
30 | 20 | } |
31 | 21 | |
32 | | -} |
\ No newline at end of file |
| 22 | +} |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestCase.php |
— | — | @@ -1,9 +1,4 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { |
4 | | - echo "This script cannot be run standalone"; |
5 | | - exit( 1 ); |
6 | | -} |
7 | | - |
8 | 3 | class SeleniumTestCase extends PHPUnit_Framework_TestCase { // PHPUnit_Extensions_SeleniumTestCase |
9 | 4 | protected $selenium; |
10 | 5 | |
— | — | @@ -31,4 +26,4 @@ |
32 | 27 | $this->assertRegExp( "/$text/", $innerHTML ); |
33 | 28 | } |
34 | 29 | |
35 | | -} |
\ No newline at end of file |
| 30 | +} |
Index: trunk/phase3/maintenance/tests/selenium/Selenium.php |
— | — | @@ -4,21 +4,16 @@ |
5 | 5 | * This is implemented as a singleton. |
6 | 6 | */ |
7 | 7 | |
8 | | -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { |
9 | | - echo "This script cannot be run standalone"; |
10 | | - exit( 1 ); |
11 | | -} |
12 | | - |
13 | 8 | class Selenium extends Testing_Selenium { |
14 | 9 | protected static $_instance = null; |
15 | 10 | public $isStarted = false; |
16 | 11 | |
17 | 12 | public static function getInstance() { |
18 | 13 | global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser; |
19 | | - global $wgSeleniumTestsWikiUrl, $wgSeleniumServerPort; |
| 14 | + global $wgSeleniumServerPort; |
20 | 15 | if ( null === self::$_instance ) { |
21 | 16 | self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], |
22 | | - $wgSeleniumTestsWikiUrl, |
| 17 | + self::getBaseUrl(), |
23 | 18 | $wgSeleniumTestsSeleniumHost, |
24 | 19 | $wgSeleniumServerPort ); |
25 | 20 | } |
— | — | @@ -36,23 +31,27 @@ |
37 | 32 | $this->isStarted = false; |
38 | 33 | } |
39 | 34 | |
| 35 | + static function getBaseUrl() { |
| 36 | + global $wgSeleniumTestsWikiUrl, $wgServer, $wgScriptPath; |
| 37 | + if ( $wgSeleniumTestsWikiUrl ) { |
| 38 | + return $wgSeleniumTestsWikiUrl; |
| 39 | + } else { |
| 40 | + return $wgServer . $wgScriptPath; |
| 41 | + } |
| 42 | + } |
| 43 | + |
40 | 44 | public function login() { |
41 | | - global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl, $wgVersion; |
| 45 | + global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword; |
42 | 46 | |
43 | | - $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=Special:Userlogin' ); |
| 47 | + $this->open( self::getBaseUrl() . '/index.php?title=Special:Userlogin' ); |
44 | 48 | $this->type( 'wpName1', $wgSeleniumTestsWikiUser ); |
45 | 49 | $this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword ); |
46 | | - if (version_compare($wgVersion, '1.15.2', '>=')) { |
47 | | - $this->click( "//input[@id='wpLoginAttempt']" ); |
48 | | - } else { |
49 | | - $this->click( "//input[@id='wpLoginattempt']" ); |
50 | | - } |
| 50 | + $this->click( "//input[@id='wpLoginAttempt']" ); |
51 | 51 | $value = $this->doCommand( 'assertTitle', array( 'Login successful*' ) ); |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function loadPage( $title, $action ) { |
55 | | - global $wgSeleniumTestsWikiUrl; |
56 | | - $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=' . $title . '&action=' . $action ); |
| 55 | + $this->open( self::getBaseUrl() . '/index.php?title=' . $title . '&action=' . $action ); |
57 | 56 | } |
58 | 57 | |
59 | 58 | // Prevent external cloning |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestConsoleLogger.php |
— | — | @@ -1,8 +1,4 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { |
4 | | - echo "This script cannot be run standalone"; |
5 | | - exit( 1 ); |
6 | | -} |
7 | 3 | |
8 | 4 | class SeleniumTestConsoleLogger { |
9 | 5 | public function __construct() { |
— | — | @@ -17,13 +13,13 @@ |
18 | 14 | |
19 | 15 | public function write( $message, $mode = false ) { |
20 | 16 | $out = ''; |
21 | | - // if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= '<font color="green">'; |
| 17 | + // if ( $mode == SeleniumTestSuite::RESULT_OK ) $out .= '<font color="green">'; |
22 | 18 | $out .= htmlentities( $message ); |
23 | | - // if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= '</font>'; |
24 | | - if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) { |
| 19 | + // if ( $mode == SeleniumTestSuite::RESULT_OK ) $out .= '</font>'; |
| 20 | + if ( $mode != SeleniumTestSuite::CONTINUE_LINE ) { |
25 | 21 | $out .= "\n"; |
26 | 22 | } |
27 | 23 | |
28 | 24 | echo $out; |
29 | 25 | } |
30 | | -} |
\ No newline at end of file |
| 26 | +} |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestHTMLLogger.php |
— | — | @@ -1,22 +1,10 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { |
4 | | - echo "This script cannot be run standalone"; |
5 | | - exit( 1 ); |
6 | | -} |
7 | 3 | |
8 | 4 | class SeleniumTestHTMLLogger { |
9 | | - public function __construct() { |
10 | | - // Prepare testsuite for immediate output |
11 | | - @ini_set( 'zlib.output_compression', 0 ); |
12 | | - @ini_set( 'implicit_flush', 1 ); |
13 | | - for ( $i = 0; $i < ob_get_level(); $i++ ) { |
14 | | - ob_end_flush(); |
15 | | - } |
16 | | - ob_implicit_flush( 1 ); |
17 | | - |
18 | | - // Output some style information |
19 | | - echo '<style> |
20 | | - pre { |
| 5 | + public function setHeaders() { |
| 6 | + global $wgOut; |
| 7 | + $wgOut->addHeadItem( 'selenium', '<style> |
| 8 | + .selenium pre { |
21 | 9 | overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */ |
22 | 10 | white-space: pre-wrap; /* css-3 */ |
23 | 11 | white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ |
— | — | @@ -25,22 +13,23 @@ |
26 | 14 | /* width: 99%; */ |
27 | 15 | word-wrap: break-word; /* Internet Explorer 5.5+ */ |
28 | 16 | } |
29 | | - </style>'; |
| 17 | + </style>' ); |
30 | 18 | } |
31 | 19 | |
32 | 20 | public function write( $message, $mode = false ) { |
| 21 | + global $wgOut; |
33 | 22 | $out = ''; |
34 | | - if ( $mode == MW_TESTLOGGER_RESULT_OK ) { |
| 23 | + if ( $mode == SeleniumTestSuite::RESULT_OK ) { |
35 | 24 | $out .= '<font color="green">'; |
36 | 25 | } |
37 | | - $out .= htmlentities( $message ); |
38 | | - if ( $mode == MW_TESTLOGGER_RESULT_OK ) { |
| 26 | + $out .= htmlspecialchars( $message ); |
| 27 | + if ( $mode == SeleniumTestSuite::RESULT_OK ) { |
39 | 28 | $out .= '</font>'; |
40 | 29 | } |
41 | | - if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) { |
| 30 | + if ( $mode != SeleniumTestSuite::CONTINUE_LINE ) { |
42 | 31 | $out .= '<br />'; |
43 | 32 | } |
44 | 33 | |
45 | | - echo $out; |
| 34 | + $wgOut->addHTML( $out ); |
46 | 35 | } |
47 | | -} |
\ No newline at end of file |
| 36 | +} |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumTestListener.php |
— | — | @@ -1,8 +1,4 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { |
4 | | - echo "This script cannot be run standalone"; |
5 | | - exit( 1 ); |
6 | | -} |
7 | 3 | |
8 | 4 | class SeleniumTestListener implements PHPUnit_Framework_TestListener { |
9 | 5 | private $logger; |
— | — | @@ -39,13 +35,13 @@ |
40 | 36 | public function startTest( PHPUnit_Framework_Test $test ) { |
41 | 37 | $this->logger->write( |
42 | 38 | 'Testing ' . $test->getName() . ' ... ', |
43 | | - MW_TESTLOGGER_CONTINUE_LINE |
| 39 | + SeleniumTestSuite::CONTINUE_LINE |
44 | 40 | ); |
45 | 41 | } |
46 | 42 | |
47 | 43 | public function endTest( PHPUnit_Framework_Test $test, $time ) { |
48 | 44 | if ( !$test->hasFailed() ) { |
49 | | - $this->logger->write( 'OK', MW_TESTLOGGER_RESULT_OK ); |
| 45 | + $this->logger->write( 'OK', SeleniumTestSuite::RESULT_OK ); |
50 | 46 | $this->tests_ok++; |
51 | 47 | } |
52 | 48 | } |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumLoader.php |
— | — | @@ -0,0 +1,9 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class SeleniumLoader { |
| 5 | + static function load() { |
| 6 | + require_once( 'Testing/Selenium.php' ); |
| 7 | + require_once( 'PHPUnit/Framework.php' ); |
| 8 | + require_once( 'PHPUnit/Extensions/SeleniumTestCase.php' ); |
| 9 | + } |
| 10 | +} |
Property changes on: trunk/phase3/maintenance/tests/selenium/SeleniumLoader.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 11 | + native |
Index: trunk/phase3/includes/User.php |
— | — | @@ -167,6 +167,7 @@ |
168 | 168 | 'reupload', |
169 | 169 | 'reupload-shared', |
170 | 170 | 'rollback', |
| 171 | + 'selenium', |
171 | 172 | 'sendemail', |
172 | 173 | 'siteadmin', |
173 | 174 | 'suppressionlog', |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -593,6 +593,7 @@ |
594 | 594 | 'SpecialRecentChanges' => 'includes/specials/SpecialRecentchanges.php', |
595 | 595 | 'SpecialRecentchangeslinked' => 'includes/specials/SpecialRecentchangeslinked.php', |
596 | 596 | 'SpecialSearch' => 'includes/specials/SpecialSearch.php', |
| 597 | + 'SpecialSelenium' => 'includes/specials/SpecialSelenium.php', |
597 | 598 | 'SpecialStatistics' => 'includes/specials/SpecialStatistics.php', |
598 | 599 | 'SpecialTags' => 'includes/specials/SpecialTags.php', |
599 | 600 | 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php', |
— | — | @@ -638,25 +639,40 @@ |
639 | 640 | |
640 | 641 | # maintenance |
641 | 642 | 'AnsiTermColorer' => 'maintenance/parserTests.inc', |
642 | | - 'ApiTestSetup' => 'maintenance/tests/ApiSetup.php', |
643 | 643 | 'DbTestPreviewer' => 'maintenance/parserTests.inc', |
644 | 644 | 'DbTestRecorder' => 'maintenance/parserTests.inc', |
645 | 645 | 'DeleteArchivedFilesImplementation' => 'maintenance/deleteArchivedFiles.inc', |
646 | 646 | 'DeleteArchivedRevisionsImplementation' => 'maintenance/deleteArchivedRevisions.inc', |
647 | 647 | 'DummyTermColorer' => 'maintenance/parserTests.inc', |
648 | | - 'MediaWikiTestSetup' => 'maintenance/tests/MediaWiki_Setup.php', |
649 | | - 'PHPUnitTestRecorder' => 'maintenance/tests/ParserHelpers.php', |
650 | 648 | 'ParserTest' => 'maintenance/parserTests.inc', |
651 | 649 | 'ParserTestParserHook' => 'maintenance/parserTestsParserHook.php', |
652 | 650 | 'ParserTestStaticParserHook' => 'maintenance/parserTestsStaticParserHook.php', |
653 | | - 'ParserTestSuiteBackend' => 'maintenance/tests/ParserHelpers.php', |
654 | | - 'ParserUnitTest' => 'maintenance/tests/ParserHelpers.php', |
655 | 651 | 'RemoteTestRecorder' => 'maintenance/parserTests.inc', |
656 | | - 'SearchEngineTest' => 'maintenance/tests/SearchEngineTest.php', |
657 | 652 | 'SevenZipStream' => 'maintenance/7zip.inc', |
658 | 653 | 'TestFileIterator' => 'maintenance/parserTests.inc', |
659 | 654 | 'TestRecorder' => 'maintenance/parserTests.inc', |
| 655 | + |
| 656 | + # maintenance/tests |
| 657 | + 'ApiTestSetup' => 'maintenance/tests/ApiSetup.php', |
| 658 | + 'MediaWikiTestSetup' => 'maintenance/tests/MediaWiki_Setup.php', |
| 659 | + 'PHPUnitTestRecorder' => 'maintenance/tests/ParserHelpers.php', |
| 660 | + 'ParserTestSuiteBackend' => 'maintenance/tests/ParserHelpers.php', |
| 661 | + 'ParserUnitTest' => 'maintenance/tests/ParserHelpers.php', |
| 662 | + 'SearchEngineTest' => 'maintenance/tests/SearchEngineTest.php', |
660 | 663 | 'UploadFromUrlTest' => 'maintenance/tests/UploadFromUrlTest.php', |
| 664 | + |
| 665 | + # maintenance/tests/selenium |
| 666 | + 'SimpleSeleniumTest' => 'maintenance/tests/selenium/SimpleSeleniumTest.php', |
| 667 | + 'Selenium' => 'maintenance/tests/selenium/Selenium.php', |
| 668 | + 'SeleniumLoader' => 'maintenance/tests/selenium/SeleniumLoader.php', |
| 669 | + 'SeleniumTestCase' => 'maintenance/tests/selenium/SeleniumTestCase.php', |
| 670 | + 'SeleniumTestConsoleLogger' => 'maintenance/tests/selenium/SeleniumTestConsoleLogger.php', |
| 671 | + 'SeleniumTestHTMLLogger' => 'maintenance/tests/selenium/SeleniumTestHTMLLogger.php', |
| 672 | + 'SeleniumTestListener' => 'maintenance/tests/selenium/SeleniumTestListener.php', |
| 673 | + 'SeleniumTestSuite' => 'maintenance/tests/selenium/SeleniumTestSuite.php', |
| 674 | + 'SimpleSeleniumTest' => 'maintenance/tests/selenium/SimpleSeleniumTest.php', |
| 675 | + |
| 676 | + # maintenance/language |
661 | 677 | 'csvStatsOutput' => 'maintenance/language/StatOutputs.php', |
662 | 678 | 'statsOutput' => 'maintenance/language/StatOutputs.php', |
663 | 679 | 'textStatsOutput' => 'maintenance/language/StatOutputs.php', |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -3701,6 +3701,50 @@ |
3702 | 3702 | */ |
3703 | 3703 | $wgParserTestRemote = false; |
3704 | 3704 | |
| 3705 | +/** |
| 3706 | + * Enable Selenium test framework. |
| 3707 | + * This enables maintenance/tests/RunSeleniumTests.php and [[Special:Selenium]]. |
| 3708 | + */ |
| 3709 | +$wgEnableSelenium = false; |
| 3710 | + |
| 3711 | +/** List of Selenium test classes. These must be registered with the autoloader. */ |
| 3712 | +$wgSeleniumTests = array( |
| 3713 | + 'SimpleSeleniumTest' |
| 3714 | +); |
| 3715 | + |
| 3716 | + |
| 3717 | +/** Hostname of selenium server */ |
| 3718 | +$wgSeleniumTestsSeleniumHost = 'localhost'; |
| 3719 | + |
| 3720 | +/** URL of the wiki to be tested. By default, the local wiki is used. */ |
| 3721 | +$wgSeleniumTestsWikiUrl = false; |
| 3722 | + |
| 3723 | +/** Port used by selenium server. */ |
| 3724 | +$wgSeleniumServerPort = 4444; |
| 3725 | + |
| 3726 | +/** Wiki login username. Used by Selenium to log onto the wiki. */ |
| 3727 | +$wgSeleniumTestsWikiUser = 'Wikiuser'; |
| 3728 | + |
| 3729 | +/** Wiki login password. Used by Selenium to log onto the wiki. */ |
| 3730 | +$wgSeleniumTestsWikiPassword = ''; |
| 3731 | + |
| 3732 | +/** |
| 3733 | + * Common browsers on Windows platform. Modify for other platforms or |
| 3734 | + * other Windows browsers. |
| 3735 | + * Use the *chrome handler in order to be able to test file uploads. |
| 3736 | + * 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/ |
| 3737 | + */ |
| 3738 | +$wgSeleniumTestsBrowsers = array( |
| 3739 | + 'firefox' => '*firefox /usr/bin/firefox', |
| 3740 | + 'iexplorer' => '*iexploreproxy', |
| 3741 | + 'opera' => '*chrome /usr/bin/opera', |
| 3742 | +); |
| 3743 | + |
| 3744 | +/** Actually, use this browser */ |
| 3745 | +$wgSeleniumTestsUseBrowser = 'firefox'; |
| 3746 | + |
| 3747 | + |
| 3748 | + |
3705 | 3749 | /** @} */ # end of profiling, testing and debugging } |
3706 | 3750 | |
3707 | 3751 | /************************************************************************//** |
Index: trunk/phase3/includes/specials/SpecialSelenium.php |
— | — | @@ -0,0 +1,62 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * TODO: remove this feature |
| 6 | + */ |
| 7 | + |
| 8 | +class SpecialSelenium extends SpecialPage { |
| 9 | + function __construct() { |
| 10 | + parent::__construct( 'Selenium', 'selenium', false ); |
| 11 | + } |
| 12 | + |
| 13 | + function getDescription() { |
| 14 | + return 'Selenium'; |
| 15 | + } |
| 16 | + |
| 17 | + function execute() { |
| 18 | + global $wgUser, $wgOut, $wgEnableSelenium, $wgRequest; |
| 19 | + |
| 20 | + if ( !$wgEnableSelenium ) { |
| 21 | + throw new MWException( |
| 22 | + 'Selenium special page invoked when it should not be registered!' ); |
| 23 | + } |
| 24 | + |
| 25 | + $this->setHeaders(); |
| 26 | + if ( !$this->userCanExecute( $wgUser ) ) { |
| 27 | + $this->displayRestrictionError(); |
| 28 | + return; |
| 29 | + } |
| 30 | + |
| 31 | + if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) { |
| 32 | + $this->runTests(); |
| 33 | + } |
| 34 | + $wgOut->addHTML( |
| 35 | + Html::openElement( 'form', array( |
| 36 | + 'method' => 'POST', |
| 37 | + 'action' => $this->getTitle()->getLocalUrl(), |
| 38 | + ) ) . |
| 39 | + Html::input( 'submit', 'Run tests', 'submit' ) . |
| 40 | + Html::hidden( 'token', $wgUser->editToken() ) . |
| 41 | + '</form>' |
| 42 | + ); |
| 43 | + } |
| 44 | + |
| 45 | + function runTests() { |
| 46 | + global $wgSeleniumTests, $wgOut; |
| 47 | + SeleniumLoader::load(); |
| 48 | + |
| 49 | + $result = new PHPUnit_Framework_TestResult; |
| 50 | + $logger = new SeleniumTestHTMLLogger; |
| 51 | + $result->addListener( new SeleniumTestListener( $logger ) ); |
| 52 | + |
| 53 | + // run tests |
| 54 | + $suite = new SeleniumTestSuite; |
| 55 | + foreach ( $wgSeleniumTests as $testClass ) { |
| 56 | + $suite->addTest( new $testClass ); |
| 57 | + } |
| 58 | + $wgOut->addHTML( '<div class="selenium">' ); |
| 59 | + $suite->run( $result ); |
| 60 | + $wgOut->addHTML( '</div>' ); |
| 61 | + } |
| 62 | +} |
| 63 | + |
Property changes on: trunk/phase3/includes/specials/SpecialSelenium.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 64 | + native |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -207,6 +207,7 @@ |
208 | 208 | static function initList() { |
209 | 209 | global $wgSpecialPages; |
210 | 210 | global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication; |
| 211 | + global $wgEnableSelenium; |
211 | 212 | |
212 | 213 | if ( self::$mListInitialised ) { |
213 | 214 | return; |
— | — | @@ -229,6 +230,10 @@ |
230 | 231 | self::$mList['Invalidateemail'] = 'EmailInvalidation'; |
231 | 232 | } |
232 | 233 | |
| 234 | + if ( $wgEnableSelenium ) { |
| 235 | + self::$mList['Selenium'] = 'SpecialSelenium'; |
| 236 | + } |
| 237 | + |
233 | 238 | # Add extension special pages |
234 | 239 | self::$mList = array_merge( self::$mList, $wgSpecialPages ); |
235 | 240 | |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1936,6 +1936,7 @@ |
1937 | 1937 | 'right-override-export-depth' => 'Export pages including linked pages up to a depth of 5', |
1938 | 1938 | 'right-sendemail' => 'Send e-mail to other users', |
1939 | 1939 | 'right-revisionmove' => 'Move revisions', |
| 1940 | +'right-selenium' => 'Run Selenium tests', |
1940 | 1941 | |
1941 | 1942 | # User rights log |
1942 | 1943 | 'rightslog' => 'User rights log', |