3 * Implements Special:Selenium
7 * @todo Remove this feature
11 * @ingroup SpecialPage
13 class SpecialSelenium
extends SpecialPage
{
14 function __construct() {
15 parent
::__construct( 'Selenium', 'selenium', false );
18 function getDescription() {
22 function execute( $par ) {
23 global $wgUser, $wgOut, $wgEnableSelenium, $wgRequest;
25 if ( !$wgEnableSelenium ) {
26 throw new MWException(
27 'Selenium special page invoked when it should not be registered!' );
31 if ( !$this->userCanExecute( $wgUser ) ) {
32 $this->displayRestrictionError();
36 if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
40 Html
::openElement( 'form', array(
42 'action' => $this->getTitle()->getLocalUrl(),
44 Html
::input( 'submit', 'Run tests', 'submit' ) .
45 Html
::hidden( 'token', $wgUser->editToken() ) .
51 global $wgSeleniumTestSuites, $wgOut, $wgSeleniumLogger;
52 SeleniumLoader
::load();
54 $result = new PHPUnit_Framework_TestResult
;
55 $wgSeleniumLogger = new SeleniumTestHTMLLogger
;
56 $result->addListener( new SeleniumTestListener( $wgSeleniumLogger ) );
57 //$wgSeleniumLogger->setHeaders();
60 $wgOut->addHTML( '<div class="selenium">' );
62 // for some really strange reason, foreach doesn't work here. It produces an infinite loop,
63 // executing only the first test suite.
64 for ( $i = 0; $i < count( $wgSeleniumTestSuites ); $i++
) {
65 $suite = new $wgSeleniumTestSuites[$i];
67 $suite->run( $result );
69 $wgOut->addHTML( '</div>' );