Remove messages.inc, rebuildLanguage.php, writeMessagesArray.inc
[mediawiki.git] / tests / phpunit / MediaWikiPHPUnitTestListener.php
blob9eeb251e13d56b16116200ad149106d6b86438cf
1 <?php
3 class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
4 /**
5 * @var string
6 */
7 protected $logChannel;
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 );
20 return $name;
23 protected function getErrorName( Exception $exception ) {
24 $name = get_class( $exception );
25 $name = "[$name] " . $exception->getMessage();
27 return $name;
30 /**
31 * An error occurred.
33 * @param PHPUnit_Framework_Test $test
34 * @param Exception $e
35 * @param float $time
37 public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
38 wfDebugLog(
39 $this->logChannel,
40 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
44 /**
45 * A failure occurred.
47 * @param PHPUnit_Framework_Test $test
48 * @param PHPUnit_Framework_AssertionFailedError $e
49 * @param float $time
51 public function addFailure( PHPUnit_Framework_Test $test,
52 PHPUnit_Framework_AssertionFailedError $e, $time
53 ) {
54 wfDebugLog(
55 $this->logChannel,
56 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
60 /**
61 * Incomplete test.
63 * @param PHPUnit_Framework_Test $test
64 * @param Exception $e
65 * @param float $time
67 public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
68 wfDebugLog(
69 $this->logChannel,
70 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
74 /**
75 * Skipped test.
77 * @param PHPUnit_Framework_Test $test
78 * @param Exception $e
79 * @param float $time
81 * @since Method available since Release 3.0.0
83 public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
84 wfDebugLog(
85 $this->logChannel,
86 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
90 /**
91 * A test suite started.
93 * @param PHPUnit_Framework_TestSuite $suite
94 * @since Method available since Release 2.2.0
96 public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
97 wfDebugLog( $this->logChannel, 'START suite ' . $suite->getName() );
101 * A test suite ended.
103 * @param PHPUnit_Framework_TestSuite $suite
104 * @since Method available since Release 2.2.0
106 public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
107 wfDebugLog( $this->logChannel, 'END suite ' . $suite->getName() );
111 * A test started.
113 * @param PHPUnit_Framework_Test $test
115 public function startTest( PHPUnit_Framework_Test $test ) {
116 wfDebugLog( $this->logChannel, 'Start test ' . $this->getTestName( $test ) );
120 * A test ended.
122 * @param PHPUnit_Framework_Test $test
123 * @param float $time
125 public function endTest( PHPUnit_Framework_Test $test, $time ) {
126 wfDebugLog( $this->logChannel, 'End test ' . $this->getTestName( $test ) );