-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Description
The Checks class will be the main class for running checks against a plugin. This class contains all the logic to collect the Plugin and Check contexts, run Preparations ahead of checks, loop over and run all Checks and collect and return the results.
Containing this logic within a single class decoupled from I/O allows this class to be used in the different contexts in which checks can run, such as WP-CLI or in the WordPress admin, without duplicating efforts and logic which is described more in detail in the Check Orchestration and Execution Approach.
The class will contain a method to return all available checks that can be run against the plugin, which is filterable so developers can extend/modify which checks should run.
Additionally, a method to run a set of checks (by default all checks) should be provided, so the entire suite of checks can be used or a plugin can be tested against one check alone as checks are provided as a list. The method can iterate through the list of checks and execute them. For example, it allows running a single check when a CLI command is executed with one check to test for a plugin and it also allows running a single check as part of running all checks for a plugin when a CLI command or even AJAX requests is initiated to test a plugin for all checks.
The Checks class is also responsible for preparation work ahead of running tests and cleanup after tests have run.
Acceptance Criteria
Checksclass is created and exists atincludes/Checker- Protected property
$check_contextshould be there which is an instance ofCheck_Context - Constructor receives the
$plugin_main_fileas an argument - Method
get_checksshould be created as public and returns the list of checks - Method
run_check_with_resultshould be created as protected and receivesCheck $checkandCheck_Result $check_resultas an arguments. - Method
run_checksshould be created as public and accepts a single parameterarray $checkswhich is an array of the check class names to run. The method will loop over the$checksarray and run each check by callingrun_check_with_result.
Tests Coverage
get_checksmethod returns the list of expected checksrun_check_with_resultruns expected check and result is stored as expectedrun_checksruns the expected checks based on the parameter passed