Skip to content

Create CLI_Runner class #14

Closed
Closed

Description

@mehulkaklotar

Description

The CLI runner class will implement the Abstract_Check_Runner and its methods to use Checks class to run checks for a plugin provided. CLI command class will invoke or use the instance of the CLI Runner class to use the methods of the Checks class to run the checks.

This issue is dependant on:

Acceptance Criteria

  • Class CLI_Runner should be created and exists at includes/Checker
  • The CLI_Runner class extends the Abstract_Check_Runner
  • The class contains a is_plugin_check() method.
    • The is_plugin_check() method accepts no parameters.
    • The is_plugin_check() method will use the global $_REQUEST['argv'] array, and any other relevant data, to determine if the current request is for the Plugin Checker via the CLI by:
    • If the above conditions are correct, the method returns true
    • If the above conditions do not match, the method returns false.
  • The class contains a protected setup_checks() method.
    • The setup_checks() method accepts no parameters.
    • The setup_checks() method will pass the plugin name from the $_REQUEST['argv'] to the Checks constructor and assign the object to the $checks property.
    • The setup_checks() method will check the $_REQUEST['argv'] array of slugs for the checks to run. If this does not exist all checks will be run from the Checks get_checks() method.
    • The Check instances retrieved from the Checks class instance get_checks() and assigned to the $checks_to_run property.
  • The class contains a run() method.
    • The run() method accepts no parameters.
    • The run() method will call the Checks class run_checks() method passing the $checks_to_run property. ($this->checks->run_checks( $this->checks_to_run ))
    • The run() method will return the instance of Check_Results returned by the run_checks() method.

Test Coverage

  • Test is_plugin_check() returns true when the $_REQUEST['argv'] array contains the expected values for a Plugin Checker CLI request.
  • Test is_plugin_check() returns false when the $_REQUEST['argv'] array does not contains the expected values for a Plugin Checker CLI request.
  • The requires_universal_preperations returns false when no Checks passed implements the Runtime_Check interface
  • The requires_universal_preperations returns true when one or more Checks passed implements the Runtime_Check interface
  • Test prepare() method returns null when the checks to run does not contain a Check that implements the Runtime_Check interface.
  • Test prepare() method returns a callable cleanup function when the checks to run contains a Check that implements the Runtime_Check interface.
  • Test run() method returns an instance of Check_Results.
  • Test Check_Results returned by run() contains no errors/warnings when running the test Empty_Check
  • Test Check_Results returned by run() contains errors when running the test Error_Check

Activity

  1. added
    [Type] Enhancement
    Infrastructure
    on Nov 23, 2022
  2. moved this from Backlog to Definition in Plugin Checkon Dec 8, 2022
  3. self-assigned this
    on Dec 8, 2022
  4. removed their assignment
    on Dec 8, 2022
  5. moved this from Definition to AC Review in Plugin Checkon Dec 8, 2022
  6. added this to the Sprint 3 milestone on Jan 9, 2023
  7. felixarntz commented on Jan 10, 2023

    @felixarntz
    Member

    @jjgrainger See my feedback in #13 (comment), the ACs here will need a lot more detail. This iteration should probably wait for the ACs on #13 though, or be tackled together (since adding ACs to #13 requires thinking about how #14 and #15 will work as well).

  8. removed this from the Sprint 3 milestone on Jan 24, 2023
  9. 3 remaining items

  10. jjgrainger commented on Jan 27, 2023

    @jjgrainger
    Contributor

    Thanks @felixarntz I've updated the AC's for you to review. Please review and assign back to me.

  11. jjgrainger commented on Jan 31, 2023

    @jjgrainger
    Contributor

    @felixarntz I've made updates here to include the new protected setup_checks() method.

  12. felixarntz commented on Jan 31, 2023

    @felixarntz
    Member

    @jjgrainger LGTM! ✅

  13. moved this from AC Review to To Do in Plugin Checkon Jan 31, 2023
  14. removed their assignment
    on Jan 31, 2023
  15. felixarntz commented on Jan 31, 2023

    @felixarntz
    Member

    @jjgrainger Actually... while the ACs generally look right, please review my feedback in #15, which applies here as well. Let's discuss in #15 and once we have made a decision update both issues accordingly.

  16. moved this from To Do to AC Review in Plugin Checkon Jan 31, 2023
  17. jjgrainger commented on Feb 1, 2023

    @jjgrainger
    Contributor

    Thanks @felixarntz

    I've added a comment to #15 (comment) suggesting an associative array of checks where the keys are slugs that could be passed by both the CLI and AJAX requests. If you agree with this approach I can update the AC's here.

  18. moved this from AC Review to To Do in Plugin Checkon Feb 2, 2023
  19. moved this from To Do to In Progress in Plugin Checkon Feb 8, 2023
  20. moved this from In Progress to Code Review in Plugin Checkon Feb 13, 2023
  21. moved this from Code Review to Done in Plugin Checkon Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Infrastructure[Type] Enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions