Skip to content

Commit c988cc2

Browse files
committed
SourceFilter test coverage
- Extracts an `AbstractSouceFilterTestCase` as both SourceMapper and SourceFilter have the same requirements. - Refactor test to use factory methods to reduce boilerplate. - Introduces tests for wildcards, globstars and question marks.
1 parent e0ea845 commit c988cc2

File tree

5 files changed

+571
-224
lines changed

5 files changed

+571
-224
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"files": [
7474
"tests/_files/deprecation-trigger/trigger_deprecation.php",
7575
"tests/unit/Event/AbstractEventTestCase.php",
76+
"tests/unit/TextUI/AbstractSouceFilterTestCase.php",
7677
"tests/unit/Framework/MockObject/TestDoubleTestCase.php",
7778
"tests/unit/Metadata/Parser/AttributeParserTestCase.php",
7879
"tests/unit/Framework/Assert/assertContainsOnlyArrayTest.php",

composer.lock

+166-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TextUI\Configuration;
11+
12+
use const DIRECTORY_SEPARATOR;
13+
use function ltrim;
14+
use function realpath;
15+
use function str_replace;
16+
use PHPUnit\Framework\TestCase;
17+
18+
abstract class AbstractSouceFilterTestCase extends TestCase
19+
{
20+
protected static function createSource(
21+
?FilterDirectoryCollection $includeDirectories = null,
22+
?FilterDirectoryCollection $excludeDirectories = null,
23+
?FileCollection $includeFiles = null,
24+
?FileCollection $excludeFiles = null,
25+
): Source {
26+
return new Source(
27+
null,
28+
false,
29+
$includeDirectories ?? FilterDirectoryCollection::fromArray([]),
30+
$includeFiles ?? FileCollection::fromArray([]),
31+
$excludeDirectories ?? FilterDirectoryCollection::fromArray([]),
32+
$excludeFiles ?? FileCollection::fromArray([]),
33+
false,
34+
false,
35+
false,
36+
false,
37+
false,
38+
false,
39+
false,
40+
false,
41+
false,
42+
[
43+
'functions' => [],
44+
'methods' => [],
45+
],
46+
false,
47+
false,
48+
false,
49+
);
50+
}
51+
52+
protected static function fixturePath(?string $subPath = null): string
53+
{
54+
$path = realpath(__DIR__ . '/../..') . '/_files/source-filter';
55+
56+
if ($subPath !== null) {
57+
$path = $path . '/' . ltrim($subPath, '/');
58+
}
59+
60+
return str_replace('/', DIRECTORY_SEPARATOR, $path);
61+
}
62+
}

0 commit comments

Comments
 (0)