|
16 | 16 | use Behat\Gherkin\Node\OutlineNode; |
17 | 17 | use Behat\Gherkin\Node\ScenarioNode; |
18 | 18 | use ErrorException; |
| 19 | +use PHPUnit\Framework\Attributes\DataProvider; |
19 | 20 | use PHPUnit\Framework\TestCase; |
20 | 21 |
|
21 | 22 | class TagFilterTest extends TestCase |
@@ -300,6 +301,40 @@ public function testTagFilterThatIsAllWhitespaceIsIgnored(): void |
300 | 301 | $this->assertTrue($result); |
301 | 302 | } |
302 | 303 |
|
| 304 | + /** |
| 305 | + * @phpstan-return list<array{string, list<string>, bool}> |
| 306 | + */ |
| 307 | + public static function providerMatchWithoutRemovingPrefix(): array |
| 308 | + { |
| 309 | + // These cases rely on the bulk of the coverage being provided by the other tests, and the knowledge that the |
| 310 | + // implementation ultimately uses the same logic to compare tags from all types of nodes. They are only intended |
| 311 | + // to be temporary until we drop legacy parsing mode, at which point we can add the `@` to all the tags in the |
| 312 | + // other tests in this file. |
| 313 | + return [ |
| 314 | + ['@wip', [], false], |
| 315 | + ['@wip', ['@slow'], false], |
| 316 | + ['@wip', ['@wip'], true], |
| 317 | + ['@wip', ['@slow', '@wip'], true], |
| 318 | + ['@tag1&&~@tag2&&@tag3', [], false], |
| 319 | + ['@tag1&&~@tag2&&@tag3', ['@tag1'], false], |
| 320 | + ['@tag1&&~@tag2&&@tag3', ['@tag1', '@tag3'], true], |
| 321 | + ['@tag1&&~@tag2&&@tag3', ['@tag1', '@tag2'], false], |
| 322 | + ['@tag1&&~@tag2&&@tag3', ['@tag1', '@tag4'], false], |
| 323 | + ['@tag1&&~@tag2&&@tag3', ['@tag1', '@tag2', '@tag3'], false], |
| 324 | + ]; |
| 325 | + } |
| 326 | + |
| 327 | + /** |
| 328 | + * @phpstan-param list<string> $tags |
| 329 | + */ |
| 330 | + #[DataProvider('providerMatchWithoutRemovingPrefix')] |
| 331 | + public function testItMatchesTagsParsedWithoutRemovingPrefix(string $filter, array $tags, bool $expect): void |
| 332 | + { |
| 333 | + $feature = new FeatureNode(null, null, $tags, null, [], '', '', null, 1); |
| 334 | + $tagFilter = new TagFilter($filter); |
| 335 | + $this->assertSame($expect, $tagFilter->isFeatureMatch($feature)); |
| 336 | + } |
| 337 | + |
303 | 338 | private function expectDeprecationError(): void |
304 | 339 | { |
305 | 340 | set_error_handler( |
|
0 commit comments