Skip to content
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

[Task] Add dedicated tests for most Helper classes and traits #2272

Open
19 tasks
jrfnl opened this issue Jun 29, 2023 · 0 comments
Open
19 tasks

[Task] Add dedicated tests for most Helper classes and traits #2272

jrfnl opened this issue Jun 29, 2023 · 0 comments

Comments

@jrfnl
Copy link
Member

jrfnl commented Jun 29, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant