tests: mock parser tests file access
[mediawiki.git] / tests / selenium / SeleniumTestListener.php
blobdc0ac66c418e7e2ac9324f23a772e5bcf82de135
1 <?php
3 class SeleniumTestListener implements PHPUnit_Framework_TestListener {
4 private $logger;
5 private $tests_ok = 0;
6 private $tests_failed = 0;
8 public function __construct( $loggerInstance ) {
9 $this->logger = $loggerInstance;
12 public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
13 $this->logger->write( 'Error: ' . $e->getMessage() );
14 $this->tests_failed++;
17 public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
18 $this->logger->write( 'Failed: ' . $e->getMessage() );
19 $this->tests_failed++;
22 public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
23 $this->logger->write( 'Incomplete.' );
24 $this->tests_failed++;
27 public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
28 $this->logger->write( 'Skipped.' );
29 $this->tests_failed++;
32 public function startTest( PHPUnit_Framework_Test $test ) {
33 $this->logger->write(
34 'Testing ' . $test->getName() . ' ... ',
35 SeleniumTestSuite::CONTINUE_LINE
39 public function endTest( PHPUnit_Framework_Test $test, $time ) {
40 if ( !$test->hasFailed() ) {
41 $this->logger->write( 'OK', SeleniumTestSuite::RESULT_OK );
42 $this->tests_ok++;
46 public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
47 $this->logger->write( 'Testsuite ' . $suite->getName() . ' started.' );
48 $this->tests_ok = 0;
49 $this->tests_failed = 0;
52 public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
53 $this->logger->write( 'Testsuite ' . $suite->getName() . ' ended.' );
54 if ( $this->tests_ok > 0 || $this->tests_failed > 0 ) {
55 $this->logger->write( ' OK: ' . $this->tests_ok . ' Failed: ' . $this->tests_failed );
57 $this->tests_ok = 0;
58 $this->tests_failed = 0;
61 public function statusMessage( $message ) {
62 $this->logger->write( $message );