Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Check_Result class #11

Closed
Tracked by #3
mehulkaklotar opened this issue Nov 21, 2022 · 0 comments · Fixed by #50
Closed
Tracked by #3

Create Check_Result class #11

mehulkaklotar opened this issue Nov 21, 2022 · 0 comments · Fixed by #50
Labels
Infrastructure Issues for the overall plugin infrastructure [Type] Enhancement A suggestion for improvement of an existing feature
Milestone

Comments

@mehulkaklotar
Copy link
Member

mehulkaklotar commented Nov 21, 2022

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.php should exists at includes/Checker
  • Protected property $check_context should be instance of Check_Context class created here Create Check_Context class #10
  • 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
    • get_errors method returns all errors expected
    • get_warnings method returns all warnings expected
    • get_error_count method returns expected error count
    • get_warning_count method returns expected warning count
@mehulkaklotar mehulkaklotar added [Type] Enhancement A suggestion for improvement of an existing feature Infrastructure Issues for the overall plugin infrastructure labels Nov 23, 2022
@mehulkaklotar mehulkaklotar self-assigned this Dec 7, 2022
@FlicHollis FlicHollis added this to the Sprint 1 milestone Dec 7, 2022
@mehulkaklotar mehulkaklotar removed their assignment Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall plugin infrastructure [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants