MediaWiki REL1_33
MediaWikiPHPUnitTestListener.php
Go to the documentation of this file.
1<?php
2
3class MediaWikiPHPUnitTestListener extends PHPUnit_Framework_BaseTestListener {
4
8 protected $logChannel = 'PHPUnitCommand';
9
10 protected function getTestName( PHPUnit_Framework_Test $test ) {
11 $name = get_class( $test );
12
13 if ( $test instanceof PHPUnit\Framework\TestCase ) {
14 $name .= '::' . $test->getName( true );
15 }
16
17 return $name;
18 }
19
20 protected function getErrorName( Exception $exception ) {
21 $name = get_class( $exception );
22 $name = "[$name] " . $exception->getMessage();
23
24 return $name;
25 }
26
34 public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
36 $this->logChannel,
37 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
38 );
39 }
40
48 public function addFailure( PHPUnit_Framework_Test $test,
49 PHPUnit_Framework_AssertionFailedError $e, $time
50 ) {
52 $this->logChannel,
53 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
54 );
55 }
56
64 public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
66 $this->logChannel,
67 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
68 );
69 }
70
78 public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
80 $this->logChannel,
81 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
82 );
83 }
84
90 public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
91 wfDebugLog( $this->logChannel, 'START suite ' . $suite->getName() );
92 }
93
99 public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
100 wfDebugLog( $this->logChannel, 'END suite ' . $suite->getName() );
101 }
102
108 public function startTest( PHPUnit_Framework_Test $test ) {
109 Hooks::run( 'MediaWikiPHPUnitTest::startTest', [ $test ] );
110 wfDebugLog( $this->logChannel, 'Start test ' . $this->getTestName( $test ) );
111 }
112
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 ) );
122 }
123}
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
endTest(PHPUnit_Framework_Test $test, $time)
A test ended.
addError(PHPUnit_Framework_Test $test, Exception $e, $time)
An error occurred.
getTestName(PHPUnit_Framework_Test $test)
addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
Skipped test.
startTest(PHPUnit_Framework_Test $test)
A test started.
startTestSuite(PHPUnit_Framework_TestSuite $suite)
A test suite started.
endTestSuite(PHPUnit_Framework_TestSuite $suite)
A test suite ended.
addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
A failure occurred.
addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
Incomplete test.
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition hooks.txt:1802
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:271
returning false will NOT prevent logging $e
Definition hooks.txt:2175
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37