You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Abstract_Check_Runner class will contain common logic used to run Checks across both CLI and AJAX. The abstract class will be used to build out the following runner classes:
The cleanup function returned by the prepare() method is then returned.
The class has a protected requires_universal_preparations( array $checks ) method.
The method accepts an array of Check instances that will be run.
The method loops over the Check instances and tests to see if any Checks implement the Runtime_Check interface.
If any Check implements the Runtime_Check interface, the method returns true, if not, the method returns false.
The class implements a private get_shared_preparations( array $checks ) method.
The method accepts an array of Check instances that will be run.
The method assigns an empty array to a $preparations variable.
The method loops of the Check instants and tests for Checks that implement the With_Shared_Preparations interface.
If the Check implements the With_Shared_Preparations interface, the Checks get_shared_preparations method is called to return an array of preparations.
The preparations returned are checked for any duplicates by evaluating the preparation name and the array of constructor arguments to see if these match any existing shared preparations in the $preparations array.
These preparations are merged into the $preparations variable and returned by the method.
The class implements the run() method.
The run method will gather the Check instances from $this->checks->get_checks() using the requested checks in the $checks_to_run property.
The get_shared_preparations is called passing the $checks_to_run array. The returned shared preparations are then looped over calling each preparations prepare() method. The preparations cleanup functions are then stored to a $cleanups variable.
The Checks are then run by passing the $checks_to_run array is then passed to $this->checks->run_checks() and the Check_Results instanced returned stored as a variable.
If the get_shared_preparations preparations where prepared the $cleanups functions returned are called.
The run method returns the $check_results instance.
Description
The Abstract_Check_Runner class will contain common logic used to run Checks across both CLI and AJAX. The abstract class will be used to build out the following runner classes:
Acceptance Criteria
Abstract_Check_Runnerclass will exist inincludes/Checker.Check_Runnerinterface.$checksproperty.$checks_to_runproperty.is_plugin_check()method.setup_checks()method.prepare()method.prepare()method accepts no parameters.prepare()method is used to run any universal preparations early in the WordPress load.$checks_to_runarray is passed to therequires_universal_preparations()method (Create Abstract_Check_Runner class #63).Universal_Runtime_Preparationwill be used.Universal_Runtime_Preparation(Create a Universal_Runtime_Preparation #61) and call theprepare()method.prepare()method is then returned.requires_universal_preparations( array $checks )method.Runtime_Checkinterface.Runtime_Checkinterface, the method returnstrue, if not, the method returnsfalse.get_shared_preparations( array $checks )method.$preparationsvariable.With_Shared_Preparationsinterface.With_Shared_Preparationsinterface, the Checksget_shared_preparationsmethod is called to return an array of preparations.$preparationsarray.$preparationsvariable and returned by the method.run()method.runmethod will gather the Check instances from$this->checks->get_checks()using the requested checks in the$checks_to_runproperty.get_shared_preparationsis called passing the$checks_to_runarray. The returned shared preparations are then looped over calling each preparationsprepare()method. The preparations cleanup functions are then stored to a$cleanupsvariable.$checks_to_runarray is then passed to$this->checks->run_checks()and theCheck_Resultsinstanced returned stored as a variable.get_shared_preparationspreparations where prepared the$cleanupsfunctions returned are called.runmethod returns the$check_resultsinstance.