Debian Codegraph @

tests/phpunit/MWTestDox.php

raw symbols SCIP
1 <?php
2
3 use PHPUnit\Framework\Test;
4 use PHPUnit\Framework\TestFailure;
5 use PHPUnit\Util\TestDox\CliTestDoxPrinter;
6
7 /**
8 * Custom version of PHPUnit TestDox.
9 */
10 class MWTestDox extends CliTestDoxPrinter {
11
12 /**
13 * @param TestFailure $defect
14 * @return void
15 */
16 protected function printDefectTrace( TestFailure $defect ): void {
17 parent::printDefectTrace( $defect );
18 $test = $defect->getTestName();
19 $log = MediaWikiLoggerPHPUnitExtension::$testsCollection[$test] ?? null;
20 if ( $log ) {
21 $this->write( "=== Logs generated by test case\n{$log}\n===\n" );
22 }
23 }
24
25 /**
26 * Print the plain test name, not the prettified version from TestDox.
27 *
28 * @param Test $test
29 * @return string
30 */
31 protected function formatTestName( Test $test ): string {
32 return $test->getName();
33 }
34
35 /**
36 * Print the plain class name, not the prettified version from TestDox.
37 *
38 * @param Test $test
39 * @return string
40 */
41 protected function formatClassName( Test $test ): string {
42 return get_class( $test );
43 }
44
45 }