Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceFilter test coverage #6148

Conversation

dantleech
Copy link
Contributor

@dantleech dantleech commented Mar 14, 2025

This MR aims to improve the test coverage for the SourceFilter in anticipation of #6146

  • 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 (i.e.single char wildcard)

The tests are far from exhaustive as we are testing the behavior of glob in order to be able to avoid calling it in the future notably we are not testing character classes and all the variants therein - and it's an open question if PHPUnit should support that going forward? A quick scan of github doesn't reveal anybody making uses of character classes.

@dantleech dantleech force-pushed the gh-6114-source-filter-tests branch from a40b4de to c988cc2 Compare March 14, 2025 11:22
@dantleech dantleech force-pushed the gh-6114-source-filter-tests branch 2 times, most recently from b467bd6 to a676cc7 Compare March 14, 2025 11:30
- 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.
@dantleech dantleech force-pushed the gh-6114-source-filter-tests branch from a676cc7 to b69ba97 Compare March 14, 2025 11:32
FileCollection::fromArray(
),
],
'globstar with any more than a single char prefix does not include sibling files' => [
Copy link
Contributor Author

@dantleech dantleech Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this behavior (see test above too) is very strange. /<any char>** will be equivilent to /** but <more than 1 char>** will not

@sebastianbergmann sebastianbergmann added type/enhancement A new idea that should be implemented type/tests Tests! Yes, PHPUnit, too, needs tests. labels Mar 14, 2025
@sebastianbergmann sebastianbergmann merged commit c6051a2 into sebastianbergmann:main Mar 14, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A new idea that should be implemented type/tests Tests! Yes, PHPUnit, too, needs tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants