File: MWTestDox.php

package info (click to toggle)
mediawiki 1%3A1.43.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 420,592 kB
  • sloc: php: 1,064,309; javascript: 664,315; sql: 9,737; python: 5,743; xml: 3,489; sh: 1,131; makefile: 64
file content (45 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestFailure;
use PHPUnit\Util\TestDox\CliTestDoxPrinter;

/**
 * Custom version of PHPUnit TestDox.
 */
class MWTestDox extends CliTestDoxPrinter {

	/**
	 * @param TestFailure $defect
	 * @return void
	 */
	protected function printDefectTrace( TestFailure $defect ): void {
		parent::printDefectTrace( $defect );
		$test = $defect->getTestName();
		$log = MediaWikiLoggerPHPUnitExtension::$testsCollection[$test] ?? null;
		if ( $log ) {
			$this->write( "=== Logs generated by test case\n{$log}\n===\n" );
		}
	}

	/**
	 * Print the plain test name, not the prettified version from TestDox.
	 *
	 * @param Test $test
	 * @return string
	 */
	protected function formatTestName( Test $test ): string {
		return $test->getName();
	}

	/**
	 * Print the plain class name, not the prettified version from TestDox.
	 *
	 * @param Test $test
	 * @return string
	 */
	protected function formatClassName( Test $test ): string {
		return get_class( $test );
	}

}