3 class MediaWikiPHPUnitTestListener
4 extends PHPUnit_TextUI_ResultPrinter
implements PHPUnit_Framework_TestListener
{
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 );
21 protected function getErrorName( Exception
$exception ) {
22 $name = get_class( $exception );
23 $name = "[$name] " . $exception->getMessage();
31 * @param PHPUnit_Framework_Test $test
35 public function addError( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
36 parent
::addError( $test, $e, $time );
39 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
46 * @param PHPUnit_Framework_Test $test
47 * @param PHPUnit_Framework_AssertionFailedError $e
50 public function addFailure( PHPUnit_Framework_Test
$test,
51 PHPUnit_Framework_AssertionFailedError
$e, $time
53 parent
::addFailure( $test, $e, $time );
56 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
63 * @param PHPUnit_Framework_Test $test
67 public function addIncompleteTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
68 parent
::addIncompleteTest( $test, $e, $time );
71 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
78 * @param PHPUnit_Framework_Test $test
82 public function addSkippedTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
83 parent
::addSkippedTest( $test, $e, $time );
86 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
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() );
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 ) );
123 * @param PHPUnit_Framework_Test $test
126 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
127 parent
::endTest( $test, $time );
128 wfDebugLog( $this->logChannel
, 'End test ' . $this->getTestName( $test ) );