MediaWiki  1.23.15
MediaWikiPHPUnitTestListener.php
Go to the documentation of this file.
1 <?php
2 class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
3 
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 
37  public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
38  wfDebugLog( $this->logChannel, 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
39  }
40 
48  public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
49  wfDebugLog( $this->logChannel, 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
50  }
51 
59  public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
60  wfDebugLog( $this->logChannel, 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
61  }
62 
72  public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
73  wfDebugLog( $this->logChannel, 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
74  }
75 
82  public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
83  wfDebugLog( $this->logChannel, 'START suite ' . $suite->getName() );
84  }
85 
92  public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
93  wfDebugLog( $this->logChannel, 'END suite ' . $suite->getName() );
94  }
95 
101  public function startTest( PHPUnit_Framework_Test $test ) {
102  wfDebugLog( $this->logChannel, 'Start test ' . $this->getTestName( $test ) );
103  }
104 
111  public function endTest( PHPUnit_Framework_Test $test, $time ) {
112  wfDebugLog( $this->logChannel, 'End test ' . $this->getTestName( $test ) );
113  }
114 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
MediaWikiPHPUnitTestListener\startTest
startTest(PHPUnit_Framework_Test $test)
A test started.
Definition: MediaWikiPHPUnitTestListener.php:100
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1087
MediaWikiPHPUnitTestListener\addSkippedTest
addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
Skipped test.
Definition: MediaWikiPHPUnitTestListener.php:71
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
MediaWikiPHPUnitTestListener\$logChannel
string $logChannel
Definition: MediaWikiPHPUnitTestListener.php:6
MediaWikiPHPUnitTestListener\__construct
__construct( $logChannel)
Definition: MediaWikiPHPUnitTestListener.php:8
MediaWikiPHPUnitTestListener\addError
addError(PHPUnit_Framework_Test $test, Exception $e, $time)
An error occurred.
Definition: MediaWikiPHPUnitTestListener.php:36
MediaWikiPHPUnitTestListener\endTestSuite
endTestSuite(PHPUnit_Framework_TestSuite $suite)
A test suite ended.
Definition: MediaWikiPHPUnitTestListener.php:91
MediaWikiPHPUnitTestListener\addFailure
addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
A failure occurred.
Definition: MediaWikiPHPUnitTestListener.php:47
$test
$test
Definition: Utf8Test.php:89
MediaWikiPHPUnitTestListener
Definition: MediaWikiPHPUnitTestListener.php:2
MediaWikiPHPUnitTestListener\startTestSuite
startTestSuite(PHPUnit_Framework_TestSuite $suite)
A test suite started.
Definition: MediaWikiPHPUnitTestListener.php:81
MediaWikiPHPUnitTestListener\addIncompleteTest
addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
Incomplete test.
Definition: MediaWikiPHPUnitTestListener.php:58
MediaWikiPHPUnitTestListener\getTestName
getTestName(PHPUnit_Framework_Test $test)
Definition: MediaWikiPHPUnitTestListener.php:12
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
MediaWikiPHPUnitTestListener\endTest
endTest(PHPUnit_Framework_Test $test, $time)
A test ended.
Definition: MediaWikiPHPUnitTestListener.php:110
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632
MediaWikiPHPUnitTestListener\getErrorName
getErrorName(Exception $exception)
Definition: MediaWikiPHPUnitTestListener.php:22