3 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 ) {
40 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
47 * @param PHPUnit_Framework_Test $test
48 * @param PHPUnit_Framework_AssertionFailedError $e
51 public function addFailure( PHPUnit_Framework_Test
$test,
52 PHPUnit_Framework_AssertionFailedError
$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 ) {
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 ) {
84 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
89 * A test suite started.
91 * @param PHPUnit_Framework_TestSuite $suite
93 public function startTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
94 wfDebugLog( $this->logChannel
, 'START suite ' . $suite->getName() );
100 * @param PHPUnit_Framework_TestSuite $suite
102 public function endTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
103 wfDebugLog( $this->logChannel
, 'END suite ' . $suite->getName() );
109 * @param PHPUnit_Framework_Test $test
111 public function startTest( PHPUnit_Framework_Test
$test ) {
112 wfDebugLog( $this->logChannel
, 'Start test ' . $this->getTestName( $test ) );
118 * @param PHPUnit_Framework_Test $test
121 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
122 wfDebugLog( $this->logChannel
, 'End test ' . $this->getTestName( $test ) );