Fix DatabaseSqlite IDEA warnings
[mediawiki.git] / tests / phpunit / MediaWikiPHPUnitTestListener.php
blobdd606d8a4bf30a9df2f55d4b091b9b3d9b92c5f5
1 <?php
3 class MediaWikiPHPUnitTestListener
4 extends PHPUnit_TextUI_ResultPrinter implements PHPUnit_Framework_TestListener {
6 /**
7 * @var string
8 */
9 protected $logChannel = 'PHPUnitCommand';
11 protected function getTestName( PHPUnit_Framework_Test $test ) {
12 $name = get_class( $test );
14 if ( $test instanceof PHPUnit_Framework_TestCase ) {
15 $name .= '::' . $test->getName( true );
18 return $name;
21 protected function getErrorName( Exception $exception ) {
22 $name = get_class( $exception );
23 $name = "[$name] " . $exception->getMessage();
25 return $name;
28 /**
29 * An error occurred.
31 * @param PHPUnit_Framework_Test $test
32 * @param Exception $e
33 * @param float $time
35 public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
36 parent::addError( $test, $e, $time );
37 wfDebugLog(
38 $this->logChannel,
39 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
43 /**
44 * A failure occurred.
46 * @param PHPUnit_Framework_Test $test
47 * @param PHPUnit_Framework_AssertionFailedError $e
48 * @param float $time
50 public function addFailure( PHPUnit_Framework_Test $test,
51 PHPUnit_Framework_AssertionFailedError $e, $time
52 ) {
53 parent::addFailure( $test, $e, $time );
54 wfDebugLog(
55 $this->logChannel,
56 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
60 /**
61 * Incomplete test.
63 * @param PHPUnit_Framework_Test $test
64 * @param Exception $e
65 * @param float $time
67 public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
68 parent::addIncompleteTest( $test, $e, $time );
69 wfDebugLog(
70 $this->logChannel,
71 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
75 /**
76 * Skipped test.
78 * @param PHPUnit_Framework_Test $test
79 * @param Exception $e
80 * @param float $time
82 public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
83 parent::addSkippedTest( $test, $e, $time );
84 wfDebugLog(
85 $this->logChannel,
86 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
90 /**
91 * A test suite started.
93 * @param PHPUnit_Framework_TestSuite $suite
95 public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
96 parent::startTestSuite( $suite );
97 wfDebugLog( $this->logChannel, 'START suite ' . $suite->getName() );
101 * A test suite ended.
103 * @param PHPUnit_Framework_TestSuite $suite
105 public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
106 parent::endTestSuite( $suite );
107 wfDebugLog( $this->logChannel, 'END suite ' . $suite->getName() );
111 * A test started.
113 * @param PHPUnit_Framework_Test $test
115 public function startTest( PHPUnit_Framework_Test $test ) {
116 parent::startTest( $test );
117 wfDebugLog( $this->logChannel, 'Start test ' . $this->getTestName( $test ) );
121 * A test ended.
123 * @param PHPUnit_Framework_Test $test
124 * @param float $time
126 public function endTest( PHPUnit_Framework_Test $test, $time ) {
127 parent::endTest( $test, $time );
128 wfDebugLog( $this->logChannel, 'End test ' . $this->getTestName( $test ) );