3 class MediaWikiPHPUnitTestListener
extends PHPUnit_TextUI_ResultPrinter
implements PHPUnit_Framework_TestListener
{
8 protected $logChannel = 'PHPUnitCommand';
10 protected function getTestName( PHPUnit_Framework_Test
$test ) {
11 $name = get_class( $test );
13 if ( $test instanceof PHPUnit_Framework_TestCase
) {
14 $name .= '::' . $test->getName( true );
20 protected function getErrorName( Exception
$exception ) {
21 $name = get_class( $exception );
22 $name = "[$name] " . $exception->getMessage();
30 * @param PHPUnit_Framework_Test $test
34 public function addError( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
35 parent
::addError( $test, $e, $time );
38 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
45 * @param PHPUnit_Framework_Test $test
46 * @param PHPUnit_Framework_AssertionFailedError $e
49 public function addFailure( PHPUnit_Framework_Test
$test,
50 PHPUnit_Framework_AssertionFailedError
$e, $time
52 parent
::addFailure( $test, $e, $time );
55 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
62 * @param PHPUnit_Framework_Test $test
66 public function addIncompleteTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
67 parent
::addIncompleteTest( $test, $e, $time );
70 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
77 * @param PHPUnit_Framework_Test $test
81 public function addSkippedTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
82 parent
::addSkippedTest( $test, $e, $time );
85 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
90 * A test suite started.
92 * @param PHPUnit_Framework_TestSuite $suite
94 public function startTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
95 parent
::startTestSuite( $suite );
96 wfDebugLog( $this->logChannel
, 'START suite ' . $suite->getName() );
100 * A test suite ended.
102 * @param PHPUnit_Framework_TestSuite $suite
104 public function endTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
105 parent
::endTestSuite( $suite );
106 wfDebugLog( $this->logChannel
, 'END suite ' . $suite->getName() );
112 * @param PHPUnit_Framework_Test $test
114 public function startTest( PHPUnit_Framework_Test
$test ) {
115 parent
::startTest( $test );
116 wfDebugLog( $this->logChannel
, 'Start test ' . $this->getTestName( $test ) );
122 * @param PHPUnit_Framework_Test $test
125 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
126 parent
::endTest( $test, $time );
127 wfDebugLog( $this->logChannel
, 'End test ' . $this->getTestName( $test ) );