Merge "Installer: properly override default $wgLogo value"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiPHPUnitTestListener.php
1 <?php
2
3 class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
4 /**
5 * @var string
6 */
7 protected $logChannel;
8
9 public function __construct( $logChannel ) {
10 $this->logChannel = $logChannel;
11 }
12
13 protected function getTestName( PHPUnit_Framework_Test $test ) {
14 $name = get_class( $test );
15
16 if ( $test instanceof PHPUnit_Framework_TestCase ) {
17 $name .= '::' . $test->getName( true );
18 }
19
20 return $name;
21 }
22
23 protected function getErrorName( Exception $exception ) {
24 $name = get_class( $exception );
25 $name = "[$name] " . $exception->getMessage();
26
27 return $name;
28 }
29
30 /**
31 * An error occurred.
32 *
33 * @param PHPUnit_Framework_Test $test
34 * @param Exception $e
35 * @param float $time
36 */
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 )
41 );
42 }
43
44 /**
45 * A failure occurred.
46 *
47 * @param PHPUnit_Framework_Test $test
48 * @param PHPUnit_Framework_AssertionFailedError $e
49 * @param float $time
50 */
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 )
57 );
58 }
59
60 /**
61 * Incomplete test.
62 *
63 * @param PHPUnit_Framework_Test $test
64 * @param Exception $e
65 * @param float $time
66 */
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 )
71 );
72 }
73
74 /**
75 * Skipped test.
76 *
77 * @param PHPUnit_Framework_Test $test
78 * @param Exception $e
79 * @param float $time
80 *
81 * @since Method available since Release 3.0.0
82 */
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 )
87 );
88 }
89
90 /**
91 * A test suite started.
92 *
93 * @param PHPUnit_Framework_TestSuite $suite
94 * @since Method available since Release 2.2.0
95 */
96 public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
97 wfDebugLog( $this->logChannel, 'START suite ' . $suite->getName() );
98 }
99
100 /**
101 * A test suite ended.
102 *
103 * @param PHPUnit_Framework_TestSuite $suite
104 * @since Method available since Release 2.2.0
105 */
106 public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
107 wfDebugLog( $this->logChannel, 'END suite ' . $suite->getName() );
108 }
109
110 /**
111 * A test started.
112 *
113 * @param PHPUnit_Framework_Test $test
114 */
115 public function startTest( PHPUnit_Framework_Test $test ) {
116 wfDebugLog( $this->logChannel, 'Start test ' . $this->getTestName( $test ) );
117 }
118
119 /**
120 * A test ended.
121 *
122 * @param PHPUnit_Framework_Test $test
123 * @param float $time
124 */
125 public function endTest( PHPUnit_Framework_Test $test, $time ) {
126 wfDebugLog( $this->logChannel, 'End test ' . $this->getTestName( $test ) );
127 }
128 }