diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-09-04 05:51:59 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-09-04 05:51:59 +0200 |
commit | 91e194556c52d2f354344f930419eef2dd6267f0 (patch) | |
tree | 0cd12490d3cd3499274017c9b799d0f738d3719e /tests/selenium/SeleniumTestListener.php | |
parent | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (diff) |
Update to MediaWiki 1.21.2
Diffstat (limited to 'tests/selenium/SeleniumTestListener.php')
-rw-r--r-- | tests/selenium/SeleniumTestListener.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/selenium/SeleniumTestListener.php b/tests/selenium/SeleniumTestListener.php new file mode 100644 index 00000000..dc0ac66c --- /dev/null +++ b/tests/selenium/SeleniumTestListener.php @@ -0,0 +1,65 @@ +<?php + +class SeleniumTestListener implements PHPUnit_Framework_TestListener { + private $logger; + private $tests_ok = 0; + private $tests_failed = 0; + + 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 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 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() . ' ... ', + SeleniumTestSuite::CONTINUE_LINE + ); + } + + public function endTest( PHPUnit_Framework_Test $test, $time ) { + if ( !$test->hasFailed() ) { + $this->logger->write( 'OK', SeleniumTestSuite::RESULT_OK ); + $this->tests_ok++; + } + } + + public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) { + $this->logger->write( 'Testsuite ' . $suite->getName() . ' started.' ); + $this->tests_ok = 0; + $this->tests_failed = 0; + } + + public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) { + $this->logger->write( 'Testsuite ' . $suite->getName() . ' ended.' ); + if ( $this->tests_ok > 0 || $this->tests_failed > 0 ) { + $this->logger->write( ' OK: ' . $this->tests_ok . ' Failed: ' . $this->tests_failed ); + } + $this->tests_ok = 0; + $this->tests_failed = 0; + } + + public function statusMessage( $message ) { + $this->logger->write( $message ); + } +} + |