Skip to content

Create Check_Result class #11

@mehulkaklotar

Description

@mehulkaklotar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    InfrastructureIssues for the overall plugin infrastructure[Type] EnhancementA suggestion for improvement of an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions