-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilter.php
More file actions
144 lines (132 loc) · 4.65 KB
/
Copy pathFilter.php
File metadata and controls
144 lines (132 loc) · 4.65 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
declare(strict_types=1);
namespace Testo;
use Internal\Path;
use Testo\Core\Value\TestType;
/**
* Immutable DTO containing test filtering criteria.
*
* Can be created manually and passed to Application::run() or populated automatically
* from CLI arguments.
*
* @api
*/
final readonly class Filter
{
/**
* Test suite names to filter by.
*
* @var list<non-empty-string>
*/
public array $suites;
/**
* Class, method, or function names to filter by.
*
* Supports formats:
* - Method: ClassName::methodName or Namespace\ClassName::methodName
* - FQN: Namespace\ClassName or Namespace\functionName
* - Fragment: methodName, functionName, or ShortClassName
*
* @var list<non-empty-string>
*/
public array $names;
/**
* Absolute file or directory paths to filter by. A suite is narrowed to the include roots
* touching them, and a file passes when it is located under one of them.
*
* @var list<Path>
*/
public array $paths;
/**
* Test case types to include, e.g. 'test', 'inline', 'bench', etc. A case passes when its type
* is in this list (OR logic). An empty list means no type inclusion filter is applied.
* @see TestType
*
* @var list<non-empty-string>
*/
public array $type;
/**
* Test case types to exclude. A case is dropped when its type is in this list.
* Exclusion takes precedence over inclusion.
* @see TestType
*
* @var list<non-empty-string>
*/
public array $notType;
/**
* Group names to include. A test passes when its group set intersects this list (OR logic).
* An empty list means no group inclusion filter is applied.
*
* @see \Testo\Filter\Group
*
* @var list<non-empty-string>
*/
public array $groups;
/**
* Group names to exclude. A test is dropped when its group set intersects this list.
* Exclusion takes precedence over inclusion.
*
* @see \Testo\Filter\Group
*
* @var list<non-empty-string>
*/
public array $excludeGroups;
/**
* @param list<non-empty-string> $suites Test suite names to filter by
* @param list<non-empty-string> $names Class, method, or function names to filter by
* @param list<Path|string> $paths File or directory paths to filter by
* @param list<non-empty-string> $type Test case types to include (OR logic)
* @param list<non-empty-string> $notType Test case types to exclude (takes precedence)
* @param list<non-empty-string> $groups Group names to include (OR logic)
* @param list<non-empty-string> $excludeGroups Group names to exclude (takes precedence)
*/
public function __construct(
array $suites = [],
array $names = [],
array $paths = [],
array $type = [],
array $notType = [],
array $groups = [],
array $excludeGroups = [],
) {
$this->suites = $suites;
$this->names = $names;
$this->paths = \array_map(static fn(string|Path $p): Path => Path::create($p)->absolute(), $paths);
$this->type = $type;
$this->notType = $notType;
$this->groups = $groups;
$this->excludeGroups = $excludeGroups;
}
/**
* Create a new Filter instance with modified properties.
*
* @param list<non-empty-string>|null $testSuites New test suite names, or null to keep existing
* @param list<non-empty-string>|null $names New names, or null to keep existing
* @param list<Path|string>|null $paths New paths, or null to keep existing
* @param list<non-empty-string>|null $type New include types, or null to keep existing
* @param list<non-empty-string>|null $notType New exclude types, or null to keep existing
* @param list<non-empty-string>|null $groups New include groups, or null to keep existing
* @param list<non-empty-string>|null $excludeGroups New exclude groups, or null to keep existing
*
* @return self New Filter instance with updated properties
*/
public function with(
?array $testSuites = null,
?array $names = null,
?array $paths = null,
?array $type = null,
?array $notType = null,
?array $groups = null,
?array $excludeGroups = null,
): self {
return new self(
suites: $testSuites ?? $this->suites,
names: $names ?? $this->names,
paths: $paths ?? $this->paths,
type: $type ?? $this->type,
notType: $notType ?? $this->notType,
groups: $groups ?? $this->groups,
excludeGroups: $excludeGroups ?? $this->excludeGroups,
);
}
}