Filters: add tests for GitModified and GitStaged filters + improve existing Filter test #201
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Prelim PR to allow for safely making the changes proposed in #198.
Tests/Filters: new AbstractFilterTestCase
... to contain some basic utilities and logic for use in Filter related tests.
Includes switching the
Filter/AcceptTest
to use the new abstract and to use the available utilities.Tests/AcceptTest: use named data sets
With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed.
With tests which have a lot of data sets, this makes it interesting (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number.
Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number.
Using named data sets also documents what exactly each data set is testing.
Includes making the data type in the docblocks more specific.
Tests/AcceptTest: minor tweaks
stty
by setting the report width.Filters: add tests for GitModified and GitStaged filters
This is an initial set of tests for the
GitModified
andGitStaged
filters.The tests are largely the same for both filters as the logic under test is also largely the same.
Still, having separate test classes will allow for differentiating the tests if the logic in the filters themselves would start to diverge over time or if the output of the individual git commands would give reason to add extra tests.
Notes:
exec
has been moved to a separate method in both theGitModified
, as well as theGitStaged
class.AbstractFilterTestCase
:getMockedClass()
to handle creating a mock object of the filter under test in a PHPUnit cross-version compatible manner.getBaseDir()
to get the project root directory for use as the$basedir
for the filters.getFakeFileList()
to get, as the name says, a fake file list for use in the tests, which contains a range of different file/directory situations which filter may need to take into account.Note:
.
and..
are not included as thePHP_CodeSniffer\Files\FileList
(which is basically what we're faking here) does not include those either, so that would create unrealistic test scenarios.Also note that, aside from some non-existent files added to the list for testing purposes, the files in this list do actually need to exist for the tests to be valid.
Suggested changelog entry
N/A
Related issues/external references
Related to #146
Related to #198 / #199