File: PhpUnitTestFileScannerFilter.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (50 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download
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
46
47
48
49
50
<?php

declare( strict_types = 1 );

namespace MediaWiki\Composer\PhpUnitSplitter;

use RecursiveFilterIterator;

/**
 * @license GPL-2.0-or-later
 */
class PhpUnitTestFileScannerFilter extends RecursiveFilterIterator {

	/**
	 * @var string[] list of folders and files to skip. We want to avoid
	 *               loading PHP files from the vendor folder since that's
	 *               not our code. ParserIntegrationTest is a complex suite
	 *               that we can't handle in the usual way, so we will add
	 *               that to a suite on its own, manually, as required.
	 *               Likewise `LuaSandbox\\SandboxTest` from the Scribunto
	 *               extension is a dynamic suite that generates classes
	 *               during `--list-tests-xml` which we can't run on their
	 *               own. We skip it in the scan and add it manually back
	 *               later.
	 *               `LuaEngineTestSkip` is an empty test case
	 *               generated by Scribunto's dynamic test suite when a
	 *               particular Lua engine isn't available. Since this is
	 *               just an empty test suite with a skipped test, we can
	 *               filter this from the list of test classes.
	 * @see T345481
	 */
	private const IGNORE = [
		"vendor",
		"ParserIntegrationTest.php",
		"SandboxTest.php",
		"LuaEngineTestSkip.php"
	];

	public function accept(): bool {
		$filename = $this->current()->getFilename();
		if ( $filename[0] === '.' ) {
			return false;
		}
		if ( in_array( $filename, self::IGNORE ) ) {
			return false;
		}
		return true;
	}

}