class Selenium extends Testing_Selenium
{
- protected static $_instance = null;
- public $isStarted = false;
- public static function getInstance()
- {
- global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
- if (null === self::$_instance)
- {
- self::$_instance = new self($wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost);
- }
- return self::$_instance;
- }
-
- public function start()
- {
- global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost;
- parent::start();
- $this->isStarted = true;
- }
-
- public function stop()
- {
- parent::stop();
- $this->isStarted = false;
- }
-
- public function login()
- {
- global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl;
-
- $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Special:Userlogin');
- $this->type("wpName1", $wgSeleniumTestsWikiUser);
- $this->type("wpPassword1", $wgSeleniumTestsWikiPassword);
- $this->click("//input[@id='wpLoginAttempt']");
- $value = $this->doCommand('assertTitle', array('Anmeldung erfolgreich*'));
- }
-
- public function loadPage($title, $action)
- {
- global $wgSeleniumTestsWikiUrl;
- $this->open($wgSeleniumTestsWikiUrl.'/index.php?title='.$title.'&action='.$action);
- }
-
- // Prevent external cloning
- protected function __clone() {}
- // Prevent external construction
- //protected function __construct() {}
+ protected static $_instance = null;
+ public $isStarted = false;
+ public static function getInstance()
+ {
+ global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser;
+ if (null === self::$_instance)
+ {
+ self::$_instance = new self($wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost);
+ }
+ return self::$_instance;
+ }
+
+ public function start()
+ {
+ global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost;
+ parent::start();
+ $this->isStarted = true;
+ }
+
+ public function stop()
+ {
+ parent::stop();
+ $this->isStarted = false;
+ }
+
+ public function login()
+ {
+ global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl;
+
+ $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Special:Userlogin');
+ $this->type("wpName1", $wgSeleniumTestsWikiUser);
+ $this->type("wpPassword1", $wgSeleniumTestsWikiPassword);
+ $this->click("//input[@id='wpLoginAttempt']");
+ $value = $this->doCommand('assertTitle', array('Anmeldung erfolgreich*'));
+ }
+
+ public function loadPage($title, $action)
+ {
+ global $wgSeleniumTestsWikiUrl;
+ $this->open($wgSeleniumTestsWikiUrl.'/index.php?title='.$title.'&action='.$action);
+ }
+
+ // Prevent external cloning
+ protected function __clone() {}
+ // Prevent external construction
+ //protected function __construct() {}
}
class SeleniumTestCase extends PHPUnit_Framework_TestCase //PHPUnit_Extensions_SeleniumTestCase
{
- protected $selenium;
-
- public function setUp()
- {
- set_time_limit(60);
- $this->selenium = Selenium::getInstance();
- //print_r($this->suite);
- }
-
- public function tearDown()
- {
-
- }
-
- public function __call($method, $args)
- {
- return call_user_func_array (array($this->selenium, $method), $args);
- }
-
- public function assertSeleniumAttributeEquals($attribute, $value)
- {
- $attr = $this->getAttribute($attribute);
- $this->assertEquals($attr, $value);
- }
-
- public function assertSeleniumHTMLContains($element, $text)
- {
- $innerHTML = $this->getText($element);
- //or assertContains
- $this->assertRegExp("/$text/", $innerHTML );
- }
+ protected $selenium;
+
+ public function setUp()
+ {
+ set_time_limit(60);
+ $this->selenium = Selenium::getInstance();
+ //print_r($this->suite);
+ }
+
+ public function tearDown()
+ {
+
+ }
+
+ public function __call($method, $args)
+ {
+ return call_user_func_array (array($this->selenium, $method), $args);
+ }
+
+ public function assertSeleniumAttributeEquals($attribute, $value)
+ {
+ $attr = $this->getAttribute($attribute);
+ $this->assertEquals($attr, $value);
+ }
+
+ public function assertSeleniumHTMLContains($element, $text)
+ {
+ $innerHTML = $this->getText($element);
+ //or assertContains
+ $this->assertRegExp("/$text/", $innerHTML );
+ }
}
class SeleniumTestConsoleLogger
{
- public function __construct()
- {
- // Prepare testsuite for immediate output
- @ini_set('zlib.output_compression', 0);
- @ini_set('implicit_flush', 1);
- for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
- ob_implicit_flush(1);
-
- }
+ public function __construct()
+ {
+ // Prepare testsuite for immediate output
+ @ini_set('zlib.output_compression', 0);
+ @ini_set('implicit_flush', 1);
+ for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
+ ob_implicit_flush(1);
+
+ }
- public function write($message, $mode = false)
- {
- $out .= '';
- //if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '<font color="green">';
- $out .= htmlentities($message);
- //if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '</font>';
- if ($mode != MW_TESTLOGGER_CONTINUE_LINE) $out .= "\n";
+ public function write($message, $mode = false)
+ {
+ $out .= '';
+ //if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '<font color="green">';
+ $out .= htmlentities($message);
+ //if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '</font>';
+ if ($mode != MW_TESTLOGGER_CONTINUE_LINE) $out .= "\n";
- echo $out;
- }
+ echo $out;
+ }
}
\ No newline at end of file
class SeleniumTestHTMLLogger
{
- public function __construct()
- {
- // Prepare testsuite for immediate output
- @ini_set('zlib.output_compression', 0);
- @ini_set('implicit_flush', 1);
- for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
- ob_implicit_flush(1);
-
- // Output some style information
- echo '<style>
- pre {
- overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
- white-space: pre-wrap; /* css-3 */
- white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
- white-space: -pre-wrap; /* Opera 4-6 */
- white-space: -o-pre-wrap; /* Opera 7 */
- /* width: 99%; */
- word-wrap: break-word; /* Internet Explorer 5.5+ */
- }
- </style>';
-
-
- }
+ public function __construct()
+ {
+ // Prepare testsuite for immediate output
+ @ini_set('zlib.output_compression', 0);
+ @ini_set('implicit_flush', 1);
+ for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
+ ob_implicit_flush(1);
+
+ // Output some style information
+ echo '<style>
+ pre {
+ overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ /* width: 99%; */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+ }
+ </style>';
+
+
+ }
- public function write($message, $mode = false)
- {
- $out .= '';
- if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '<font color="green">';
- $out .= htmlentities($message);
- if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '</font>';
- if ($mode != MW_TESTLOGGER_CONTINUE_LINE) $out .= '<br/>';
+ public function write($message, $mode = false)
+ {
+ $out .= '';
+ if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '<font color="green">';
+ $out .= htmlentities($message);
+ if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= '</font>';
+ if ($mode != MW_TESTLOGGER_CONTINUE_LINE) $out .= '<br/>';
- echo $out;
- }
+ echo $out;
+ }
}
\ No newline at end of file
class SeleniumTestListener implements PHPUnit_Framework_TestListener
{
- private $logger;
- private $tests_ok = 0;
- private $tests_failed = 0;
+ private $logger;
+ private $tests_ok = 0;
+ private $tests_failed = 0;
- public function __construct($loggerInstance)
- {
- $this->logger = $loggerInstance;
- }
+ public function __construct($loggerInstance)
+ {
+ $this->logger = $loggerInstance;
+ }
- public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
- {
- $this->logger->write("Error: ".$e->getMessage());
- $this->tests_failed++;
- }
+ public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->logger->write("Error: ".$e->getMessage());
+ $this->tests_failed++;
+ }
- public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
- {
- $this->logger->write("Failed: ".$e->getMessage());
- $this->tests_failed++;
+ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
+ {
+ $this->logger->write("Failed: ".$e->getMessage());
+ $this->tests_failed++;
- }
+ }
- public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
- {
- $this->logger->write("Incomplete.");
- $this->tests_failed++;
- }
+ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->logger->write("Incomplete.");
+ $this->tests_failed++;
+ }
- public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
- {
- $this->logger->write("Skipped.");
- $this->tests_failed++;
- }
+ public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
+ {
+ $this->logger->write("Skipped.");
+ $this->tests_failed++;
+ }
- public function startTest(PHPUnit_Framework_Test $test)
- {
- $this->logger->write("Testing ".$test->getName()." ... ", MW_TESTLOGGER_CONTINUE_LINE);
- }
+ public function startTest(PHPUnit_Framework_Test $test)
+ {
+ $this->logger->write("Testing ".$test->getName()." ... ", MW_TESTLOGGER_CONTINUE_LINE);
+ }
- public function endTest(PHPUnit_Framework_Test $test, $time)
- {
- if (!$test->hasFailed())
- {
- $this->logger->write("OK", MW_TESTLOGGER_RESULT_OK);
- $this->tests_ok++;
- }
- }
+ public function endTest(PHPUnit_Framework_Test $test, $time)
+ {
+ if (!$test->hasFailed())
+ {
+ $this->logger->write("OK", MW_TESTLOGGER_RESULT_OK);
+ $this->tests_ok++;
+ }
+ }
- public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
- {
- $this->logger->write("Testsuite ".$suite->getName()." started.");
- $this->tests_ok = 0;
- }
+ public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ $this->logger->write("Testsuite ".$suite->getName()." started.");
+ $this->tests_ok = 0;
+ }
- public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
- {
- $this->logger->write("Testsuite ".$suite->getName()." ended. OK: ".$this->tests_ok." Failed: ".$this->tests_failed);
+ public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
+ {
+ $this->logger->write("Testsuite ".$suite->getName()." ended. OK: ".$this->tests_ok." Failed: ".$this->tests_failed);
- }
+ }
- public function statusMessage($message)
- {
- $this->logger->write($message);
- }
+ public function statusMessage($message)
+ {
+ $this->logger->write($message);
+ }
}
class SeleniumTestSuite extends PHPUnit_Framework_TestSuite
{
- private $selenium;
-
- public function setUp()
- {
-
- $this->selenium = Selenium::getInstance();
- $this->selenium->start();
- $this->login();
- //$this->loadPage('Testpage', 'edit');
- }
-
- public function tearDown()
- {
- $this->selenium->stop();
- }
-
- public function login()
- {
- $this->selenium->login();
- }
-
- public function loadPage($title, $action)
- {
- $this->selenium->loadPage($title, $action);
- }
+ private $selenium;
+
+ public function setUp()
+ {
+
+ $this->selenium = Selenium::getInstance();
+ $this->selenium->start();
+ $this->login();
+ //$this->loadPage('Testpage', 'edit');
+ }
+
+ public function tearDown()
+ {
+ $this->selenium->stop();
+ }
+
+ public function login()
+ {
+ $this->selenium->login();
+ }
+
+ public function loadPage($title, $action)
+ {
+ $this->selenium->loadPage($title, $action);
+ }
}