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

Common::getSniffCode(): add tests, more defensive coding and minor simplification #524

Merged
merged 5 commits into from
Sep 29, 2024

Commits on Sep 29, 2024

  1. Common::getSniffCode(): add tests

    Add initial set of tests for the `Common::getSniffCode()` method.
    
    Related to 146
    Related to [review comment in PR 446](#446 (comment)).
    jrfnl committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    9b837dd View commit details
    Browse the repository at this point in the history
  2. Common::getSniffCode(): throw exception on invalid input [1]

    Previously, if an empty string was passed, the `Common::getSniffCode()` method would return `..`, which is just confusing (and incorrect).
    
    This commit changes the behaviour to throw an `InvalidArgumentException` instead.
    
    Includes making a potentially superfluous function call to the method conditionally (as it could hit the new exception).
    
    Includes test.
    jrfnl committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    5fac554 View commit details
    Browse the repository at this point in the history
  3. Common::getSniffCode(): throw exception on invalid input [2a]

    Previously, if an invalid (incomplete) class name was passed, the `Common::getSniffCode()` method would return a garbled name, like `.Qualified.C`, which is just confusing.
    
    This commit changes the behaviour to throw an `InvalidArgumentException` instead.
    
    Includes test.
    jrfnl committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    1719a66 View commit details
    Browse the repository at this point in the history
  4. Common::getSniffCode(): throw exception on invalid input [2b]

    Previously, if an invalid class name was passed, which didn't end on `Sniff` or `UnitTest`, the `Common::getSniffCode()` method would return a garbled name, like `Fully.Qualified.C`, which is just confusing.
    
    This commit changes the behaviour to throw an `InvalidArgumentException` instead.
    
    Includes test.
    jrfnl committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    2aac9ad View commit details
    Browse the repository at this point in the history
  5. Common::getSniffCode(): minor simplification

    * Remove the use of `array_pop()` in favour of directly referencing the required "parts" by their index in the array.
    * Remove the unused `$sniffDir` variable.
    * Remove the unnecessary `$code` variable.
    
    Related to [review comment in PR 446](#446 (comment)).
    jrfnl committed Sep 29, 2024
    Configuration menu
    Copy the full SHA
    7449b29 View commit details
    Browse the repository at this point in the history