| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace MediaWiki\Composer\PhpUnitSplitter; |
| 6 | |
| 7 | use RecursiveFilterIterator; |
| 8 | |
| 9 | /** |
| 10 | * @license GPL-2.0-or-later |
| 11 | */ |
| 12 | class PhpUnitTestFileScannerFilter extends RecursiveFilterIterator { |
| 13 | |
| 14 | /** |
| 15 | * @var string[] list of folders and files to skip. We want to avoid |
| 16 | * loading PHP files from the vendor folder since that's |
| 17 | * not our code. ParserIntegrationTest is a complex suite |
| 18 | * that we can't handle in the usual way, so we will add |
| 19 | * that to a suite on its own, manually, as required. |
| 20 | * `LuaEngineTestSkip` is an empty test case |
| 21 | * generated by Scribunto's dynamic test suite when a |
| 22 | * particular Lua engine isn't available. Since this is |
| 23 | * just an empty test suite with a skipped test, we can |
| 24 | * filter this from the list of test classes. |
| 25 | * @see T345481 |
| 26 | */ |
| 27 | private const IGNORE = [ |
| 28 | "vendor", |
| 29 | "ParserIntegrationTest.php", |
| 30 | "LuaEngineTestSkip.php", |
| 31 | ]; |
| 32 | |
| 33 | public function accept(): bool { |
| 34 | $filename = $this->current()->getFilename(); |
| 35 | if ( $filename[0] === '.' ) { |
| 36 | return false; |
| 37 | } |
| 38 | if ( in_array( $filename, self::IGNORE ) ) { |
| 39 | return false; |
| 40 | } |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | } |