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 AJAX runner class will implement the Abstract_Check_Runner and its methods to use the Checks class to run checks for a plugin provided. The AJAX function to handle the plugin check requests will use the instance of the AJAX runner class and call the run() method to run the checks.
Class AJAX_Runner should be created and exists at includes/Checker
The AJAX_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 array, and any other relevant data, to determine if the current request is for the Plugin Checker via an AJAX request by:
Checking the requested URL matches admin-ajax.php.
Checking the nonce passed is valid.
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 $_REQUEST['plugin'] to the Checks constructor and assign the object to the $checks property.
The setup_checks() method will check the $_REQUEST['checks'] array. As it is an AJAX request only 1 check should be passed in this array. This array contains an list of Check slugs to match with those in the Checks class.
The check slugs array is compared with the Check instances retrieved from the Checks class instance get_checks()
The array of Check objects are 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 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 array contains the expected values for a Plugin Checker AJAX request.
Test is_plugin_check() returns false when the $_REQUEST array does not contains the expected values for a Plugin Checker AJAX 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 $_REQUEST['checks'] array does not contain a Check that implements the Runtime_Check interface.
Test prepare() method returns a callable cleanup function when the $_REQUEST['checks'] array 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
Description
The AJAX runner class will implement the
Abstract_Check_Runnerand its methods to use the Checks class to run checks for a plugin provided. The AJAX function to handle the plugin check requests will use the instance of the AJAX runner class and call therun()method to run the checks.This issue is dependant on:
Acceptance Criteria
AJAX_Runnershould be created and exists atincludes/CheckerAJAX_Runnerclass extends theAbstract_Check_Runner.is_plugin_check()method.is_plugin_check()method accepts no parameters.is_plugin_check()method will use the global$_REQUESTarray, and any other relevant data, to determine if the current request is for the Plugin Checker via an AJAX request by:$_REQUEST['action']matchesplugin_check_run_checks(see WP Admin Screen - Tools page #31)admin-ajax.php.truefalse.setup_checks()method.setup_checks()method accepts no parameters.setup_checks()method will pass the$_REQUEST['plugin']to theChecksconstructor and assign the object to the$checksproperty.setup_checks()method will check the$_REQUEST['checks']array. As it is an AJAX request only 1 check should be passed in this array. This array contains an list of Check slugs to match with those in theChecksclass.Checksclass instanceget_checks()Checkobjects are assigned to the$checks_to_runproperty.run()method.run()method accepts no parameters.run()method will call theChecksclassrun_checks()method passing the$checksproperty. ($this->checks->run_checks( $this->checks_to_run ))run()method will return the instance ofCheck_Resultsreturned by therun_checks()method.Test Coverage
is_plugin_check()returnstruewhen the$_REQUESTarray contains the expected values for a Plugin Checker AJAX request.is_plugin_check()returnsfalsewhen the$_REQUESTarray does not contains the expected values for a Plugin Checker AJAX request.requires_universal_preperationsreturns false when no Checks passed implements theRuntime_Checkinterfacerequires_universal_preperationsreturns true when one or more Checks passed implements theRuntime_Checkinterfaceprepare()method returnsnullwhen the$_REQUEST['checks']array does not contain aCheckthat implements theRuntime_Checkinterface.prepare()method returns acallablecleanup function when the$_REQUEST['checks']array contains aCheckthat implements theRuntime_Checkinterface.run()method returns an instance ofCheck_Results.Check_Resultsreturned byrun()contains no errors/warnings when running the testEmpty_CheckCheck_Resultsreturned byrun()contains errors when running the testError_Check