3 class MediaWikiPHPUnitTestListener
extends PHPUnit_Framework_BaseTestListener
{
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 ) {
37 '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,
49 PHPUnit_Framework_AssertionFailedError
$e, $time
53 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
60 * @param PHPUnit_Framework_Test $test
64 public function addIncompleteTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
67 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
74 * @param PHPUnit_Framework_Test $test
78 public function addSkippedTest( PHPUnit_Framework_Test
$test, Exception
$e, $time ) {
81 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
86 * A test suite started.
88 * @param PHPUnit_Framework_TestSuite $suite
90 public function startTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
91 wfDebugLog( $this->logChannel
, 'START suite ' . $suite->getName() );
97 * @param PHPUnit_Framework_TestSuite $suite
99 public function endTestSuite( PHPUnit_Framework_TestSuite
$suite ) {
100 wfDebugLog( $this->logChannel
, 'END suite ' . $suite->getName() );
106 * @param PHPUnit_Framework_Test $test
108 public function startTest( PHPUnit_Framework_Test
$test ) {
109 Hooks
::run( 'MediaWikiPHPUnitTest::startTest', [ $test ] );
110 wfDebugLog( $this->logChannel
, 'Start test ' . $this->getTestName( $test ) );
116 * @param PHPUnit_Framework_Test $test
119 public function endTest( PHPUnit_Framework_Test
$test, $time ) {
120 Hooks
::run( 'MediaWikiPHPUnitTest::endTest', [ $test, $time ] );
121 wfDebugLog( $this->logChannel
, 'End test ' . $this->getTestName( $test ) );