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
Helper traits
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:
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
TestCaseas the base class, while when token walking is needed, we can use theUtilityMethodTestCaseform PHPCSUtils as a base class.I propose we add these tests as a separate
WPCSSniffHelperstest suite to the PHPUnit configuration.I propose we add these tests in a
Helperssubdirectory of theTestsdirectory 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-devdirective to thecomposer.jsonfile 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
@coverstag(s) for that Helper in sniff specific tests classes should be removed.Action list
Helper classes
ArrayWalkingFunctionsHelperFormattingFunctionsHelper(FormattingFunctionsHelper::is_formatting_function(): add tests #2713)UnslashingFunctionsHelperis_unslashing_function: UnslashingFunctionsHelper::is_unslashing_function(): add tests #2715ValidationHelperis_validated: ValidationHelper::is_validated(): add basic tests #2731WPGlobalVariablesHelperWPHookHelperget_hook_name_param: WPHookHelper::get_hook_name_param(): add basic tests #2727Helper traits
EscapingFunctionsTraitIsUnitTestTraitMinimumWPVersionTraitPrintingFunctionsTraitis_printing_function,get_printing_functions: PrintingFunctionsTrait: add tests #2716SanitizingFunctionsTraitWPDBTraitLow 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:
ConstantsHelperContextHelperis_in_function_call: ContextHelper::is_in_function_call(): add basic tests #2626is_in_type_test: ContextHelper::is_in_type_test(): add tests #2721is_in_isset_or_empty: ContextHelper::is_in_isset_or_empty(): add basic tests #2725is_in_array_comparison: ContextHelper::is_in_array_comparison(): add basic tests #2726is_token_namespaced: ContextHelper::is_token_namespaced(): add basic tests #2728DeprecationHelperListHelperRulesetPropertyHelperSnakeCaseHelperVariableHelper