[Task] Add dedicated tests for most Helper classes and traits
jrfnl opened this issue · 0 comments
The "Helper" classes and traits are currently tested via the sniff (integration) tests.
It would be preferable to have dedicated test for the Helper classes and traits though.
In most cases, setting up these tests shouldn't be hard as when no token walking is needed, we can use the PHPUnit native TestCase
as the base class, while when token walking is needed, we can use the UtilityMethodTestCase
form PHPCSUtils as a base class.
I propose we add these tests as a separate WPCSSniffHelpers
test suite to the PHPUnit configuration.
I propose we add these tests in a Helpers
subdirectory of the Tests
directory off the project root.
If a class would need multiple tests classes, a sub-subdirectory can be created using the Helper class/trait name as the directory name.
We may need to add an autoload-dev
directive to the composer.json
file specifically for these tests to get things working, as these tests won't run via the PHPCS native test framework.
When adding tests, Helper specific tests which were added to sniff test classes may be removed if they don't have added value anymore, though in most cases, it will be better to just leave them be.
When dedicated tests have been added for a Helper, the @covers
tag(s) for that Helper in sniff specific tests classes should be removed.
Action list
Helper classes
-
ArrayWalkingFunctionsHelper
-
FormattingFunctionsHelper
-
UnslashingFunctionsHelper
-
ValidationHelper
-
WPGlobalVariablesHelper
-
WPHookHelper
Helper traits
-
EscapingFunctionsTrait
-
IsUnitTestTrait
-
MinimumWPVersionTrait
-
PrintingFunctionsTrait
-
SanitizingFunctionsTrait
-
WPDBTrait
Low priority Helper classes
The following Helper classes are low(er) priority for adding dedicated tests as the methods in these are likely to move to PHPCSUtils at some point in the future:
-
ConstantsHelper
-
ContextHelper
-
DeprecationHelper
-
ListHelper
-
RulesetPropertyHelper
-
SnakeCaseHelper
-
VariableHelper