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 Check_Result class stores all errors, warnings and other messages generated by Check classes. This allows all messages to be recorded to a single repository in a compatible format and consistent API. Once the run of all checks is complete, the Check_Result class will be used to retrieve all results so that they can be presented in a format best suited for the environment (WP-CLI, WP Admin, Continuous Integration Pipeline) in which the checks were run.
The Check_Result class constructor will receive an instance of the Check_Context as an argument. This is so that additional information can be added to each check message such as the file name, path, line, and violation code (a code that is unique to the check/error/warning and can be empty) where the check message occurs. The violation code will be determined by the check itself.
Additionally, this class will contain methods and properties to track the count of errors and warnings to provide an overview of the final results.
Acceptance Criteria
The class file Check_Result.php should exists at includes/Checker
Protected property $errors and $warnings should be declared as array
Protected property $error_count and $warning_count should be declared as int
Constructor should receive Check_Context class instance as an argument
Class should have add_message method which will have $error or $warning as an argument as a violation code for the check with file name, path, line as an argument
Class should have get_errors method to get list of all errors which will return $errors
Class should have get_warnings method to get list of all errors which will return $warnings
Class should have get_error_count method to get count of errors which will return $error_count
Class should have get_warning_count method to get count of warnings which will return $warning_count
PHPUnit tests covering
add_message method adds the message with arguments to the error or warning lists and increments the counts
Description
The Check_Result class stores all errors, warnings and other messages generated by Check classes. This allows all messages to be recorded to a single repository in a compatible format and consistent API. Once the run of all checks is complete, the Check_Result class will be used to retrieve all results so that they can be presented in a format best suited for the environment (WP-CLI, WP Admin, Continuous Integration Pipeline) in which the checks were run.
The Check_Result class constructor will receive an instance of the Check_Context as an argument. This is so that additional information can be added to each check message such as the file name, path, line, and violation code (a code that is unique to the check/error/warning and can be empty) where the check message occurs. The violation code will be determined by the check itself.
Additionally, this class will contain methods and properties to track the count of errors and warnings to provide an overview of the final results.
Acceptance Criteria
Check_Result.phpshould exists atincludes/Checker$check_contextshould be instance ofCheck_Contextclass created here Create Check_Context class #10$errorsand$warningsshould be declared as array$error_countand$warning_countshould be declared as intCheck_Contextclass instance as an argumentadd_messagemethod which will have$erroror$warningas an argument as a violation code for the check with file name, path, line as an argumentget_errorsmethod to get list of all errors which will return$errorsget_warningsmethod to get list of all errors which will return$warningsget_error_countmethod to get count of errors which will return$error_countget_warning_countmethod to get count of warnings which will return$warning_countadd_messagemethod adds the message with arguments to the error or warning lists and increments the countsget_errorsmethod returns all errors expectedget_warningsmethod returns all warnings expectedget_error_countmethod returns expected error countget_warning_countmethod returns expected warning count