-
Notifications
You must be signed in to change notification settings - Fork 83
Description
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
- The class file
Check_Result.phpshould exists atincludes/Checker - Protected property
$check_contextshould be instance ofCheck_Contextclass created here Create Check_Context class #10 - Protected property
$errorsand$warningsshould be declared as array - Protected property
$error_countand$warning_countshould be declared as int - Constructor should receive
Check_Contextclass instance as an argument - Class should have
add_messagemethod which will have$erroror$warningas an argument as a violation code for the check with file name, path, line as an argument - Class should have
get_errorsmethod to get list of all errors which will return$errors - Class should have
get_warningsmethod to get list of all errors which will return$warnings - Class should have
get_error_countmethod to get count of errors which will return$error_count - Class should have
get_warning_countmethod to get count of warnings which will return$warning_count - PHPUnit tests covering
add_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