2 class MediaWikiPHPUnitTestListener
implements PHPUnit_Framework_TestListener
{
9 public function __construct( $logChannel ) {
10 $this->logChannel
= $logChannel;
13 protected function getTestName( PHPUnit_Framework_Test
$test ) {
14 $name = get_class( $test );
16 if ( $test instanceof PHPUnit_Framework_TestCase
) {
17 $name .= '::' . $test->getName( true );
23 protected function getErrorName( Exception
$exception ) {
24 $name = get_class( $exception );
25 $name = "[$name] " . $exception->getMessage();
33 * @param PHPUnit_Framework_Test $test
37 public function addError( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
38 wfDebugLog( $this->logChannel
, 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
44 * @param PHPUnit_Framework_Test $test
45 * @param PHPUnit_Framework_AssertionFailedError $e
48 public function addFailure( PHPUnit_Framework_Test
$test, PHPUnit_Framework_AssertionFailedError
$e, $time ) {
49 wfDebugLog( $this->logChannel
, 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
55 * @param PHPUnit_Framework_Test $test
59 public function addIncompleteTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
60 wfDebugLog( $this->logChannel
, 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
66 * @param PHPUnit_Framework_Test $test
70 * @since Method available since Release 3.0.0
72 public function addSkippedTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
73 wfDebugLog( $this->logChannel
, 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
77 * A test suite started.
79 * @param PHPUnit_Framework_TestSuite $suite
80 * @since Method available since Release 2.2.0
82 public function startTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
83 wfDebugLog( $this->logChannel
, 'START suite ' . $suite->getName() );
89 * @param PHPUnit_Framework_TestSuite $suite
90 * @since Method available since Release 2.2.0
92 public function endTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
93 wfDebugLog( $this->logChannel
, 'END suite ' . $suite->getName() );
99 * @param PHPUnit_Framework_Test $test
101 public function startTest( PHPUnit_Framework_Test
$test ) {
102 wfDebugLog( $this->logChannel
, 'Start test ' . $this->getTestName( $test ) );
108 * @param PHPUnit_Framework_Test $test
111 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
112 wfDebugLog( $this->logChannel
, 'End test ' . $this->getTestName( $test ) );