Tests: refactor the test framework #995
Merged
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
As things were, the test framework used a setup with custom test suites, which was based on PHPUnit 2/3 and only still worked by accident, not by design. This type of setup was deprecated in PHPUnit 4 and support has been removed completely in PHPUnit 10.
This commit updates the test framework to start using the test suite setup via the PHPUnit config file instead and removes all classes related to the custom test suite setup.
Notes:
phpunit
.No need to explicitly pass the
tests/AllTests.php
file anymore.Various global variables were used in this process and referred to in the test cases.
Those global variables are now no longer declared and all uses of these have been removed.
installed_paths
.To work around this, PR Play nice with sniff libraries with alternative unit test setups. squizlabs/PHP_CodeSniffer#1146 introduced a
PHPCS_IGNORE_TESTS
environment variable to explicitly ignore other standards than the one(s) being tested.With the changes now made, it is no longer needed to set this environment variable (once a test suite for an external standard has been made compatible with the PHPCS 4.0 test framework).
printPHPCodeSnifferTestOutput()
method anymore, the method has been removed and the "# sniff test files generated # unique error codes; # were fixable (#%)" summary line will no longer be printed at the end of a test run.A number of global variables were declared and written to by the tests to allow for that output previously.
Those global variables are now no longer declared and assignments to these has been removed.
Config
class and an array of instances of theRuleset
class have also been removed. This information is now stored inprivate static
properties in theAbstractSniffUnitTest
class.CodeSniffer.conf
file will be registered with the autoloader.Information on how to upgrade test suites for external standards which are based on the PHPCS native test framework will be included in the PHPCS 4.0 upgrade guide.
Refs:
Suggested changelog entry
Changed:
The test framework has been refactored and no longer creates a custom test suite.
- If tests for an external standard extend the PHPCS native test suite, be sure to read the upgrade guide for more detail.
Related issues/external references
Fixes #25