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

Tests: stabelize tests using the Config class #275

Merged
merged 2 commits into from
Jan 15, 2024

Commits on Jan 15, 2024

  1. Tests: new ConfigDouble test helper class

    The PHP_CodeSniffer native `Config` class contains a number of static properties.
    As the value of these static properties will be retained between instantiations of the class, config values set in one test can influence the results for another test, which makes tests unstable.
    
    This commit introduces a test "double" of the `Config` class which prevents this from happening.
    In _most_ cases, tests should be using this class instead of the "normal" Config, with the exception of select tests for the Config class itself.
    jrfnl committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    6e9d03b View commit details
    Browse the repository at this point in the history
  2. Tests: implement use of the new ConfigDouble class

    Note: for the `AbstractSniffUnitTest` class, this change has little to no effect, other than protecting the sniff tests from changes made to the static properties in the `Config` class by the `Core` tests.
    This is due to the `Config` being cached to a global variable. Fixing that is outside the scope of this PR.
    
    Related issues: squizlabs/PHP_CodeSniffer 2899 and 25.
    jrfnl committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    16ad55b View commit details
    Browse the repository at this point in the history