-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
ErrorSuppressionTest: refactor to use data providers + bug fixes for the tests #3335
Merged
gsherwood
merged 16 commits into
squizlabs:master
from
jrfnl:feature/3071-follow-up-refactor-errorsuppression-tests
May 27, 2021
Merged
ErrorSuppressionTest: refactor to use data providers + bug fixes for the tests #3335
gsherwood
merged 16 commits into
squizlabs:master
from
jrfnl:feature/3071-follow-up-refactor-errorsuppression-tests
May 27, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
…ider * Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
... as it uses a different code pattern, so doesn't fit with the other tests for the (upcoming) data provider.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
…ider * Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
As the "no suppression" test would yield no errors, the test wasn't actually testing anything as there were no errors to suppress. Fixed now by using a different sniff to test against, which does yield an error on the line being suppressed by the rest of the tests.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
This fixes two bugs in two test cases for the `testSuppressFile()` method: 1. The code snippet as was, contained a parse error (missing semi-colon after class instantiation). 2. The code snippet did not contain anything which would trigger the warning the test is looking for in the first place, so these two tests would always pass.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
**Note**: the "docblock" tests have changed to use the same basic code sample as the other tests. In practice this means that instead of having 0 errors and 0/1 warnings, they will now yield 1 error and 0/1 warnings. Functionally these tests still test the same principle. * Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
By the looks of it, combining disabling at different levels and disabling error codes wasn't covered in the tests.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
* Maintains the exact same existing tests, now using a data provider. The data provider uses keys which allows for much more descriptive output when using the PHPUnit `--testdox` option, as well as for easier debugging if/when a test would fail. * Orders the tests in logical groups in the data provider. * Switches out `assertEquals()` (loose type comparison) for `assertSame()` (strict type comparison). * Caches the `$config` and `$ruleset` for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.
jrfnl
changed the title
ErrorSuppressionTest: refactor to use data providers + test bug fixes
ErrorSuppressionTest: refactor to use data providers + bug fixes for the tests
May 8, 2021
Was a fun merge into 4.0 :) I ended up squashing the commits to make it easier, but think I captured all the changes in the commit message. Thanks - so much cleaner. |
@gsherwood I imagine so 😂 And yes, the separate commits were only there to allow for easier review of this PR as it's so huge and the review was done for 3.x branch anyhow. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow up to #3071 (comment)
This refactors all test methods in the
ErrorSuppresionTest
class to use data providers.For each of these refactors, the following comment applies:
The data provider uses keys which allows for much more descriptive output when using the PHPUnit
--testdox
option, as well as for easier debugging if/when a test would fail.assertEquals()
(loose type comparison) forassertSame()
(strict type comparison).$config
and$ruleset
for the test via static local variables to prevent the test run from becoming slower due to the change to the data provider.Notable (other) commits/commit comments
ErrorSuppressionTest: move one test case out of testSuppressLine()
... as it uses a different code pattern, so doesn't fit with the other tests for the (upcoming) data provider.
ErrorSuppressionTest: add test for midline ignore
ErrorSuppressionTest: fix bug in testSuppressScope()
As the "no suppression" test would yield no errors, the test wasn't actually testing anything as there were no errors to suppress.
Fixed now by using a different sniff to test against, which does yield an error on the line being suppressed by the rest of the tests.
ErrorSuppressionTest::testSuppressFile(): fix bugs in test
This fixes two bugs in two test cases for the
testSuppressFile()
method:ErrorSuppressionTest::testDisableSelected(): refactor to data provider
Note: the "docblock" tests have changed to use the same basic code sample as the other tests. In practice this means that instead of having 0 errors and 0/1 warnings, they will now yield 1 error and 0/1 warnings. Functionally these tests still test the same principle.
ErrorSuppressionTest::testDisableSelected(): add some more tests
By the looks of it, combining disabling at different levels and disabling error codes wasn't covered in the tests.