Skip to content

Create Plugin_Context class  #5

@mehulkaklotar

Description

@mehulkaklotar

Description

The Plugin Context class provides helper methods to return additional information about the Plugin Check plugin. This includes information such as the basename, paths and URLs of the Plugin Check plugin.

This allows checks to use this information when preparing or performing tests. For example, a check may want to create test content before running tests. This test content may be stored as a file within the Plugin Check plugin, which can be easily referenced using the methods and data stored in the Plugin_Context class.

Plugin_Context class will be instantiated in the Plugin_Main class constructor and use the main file passed which will be the absolute path of the Plugin Check plugin’s main file.

Acceptance Criteria

  • The class file Plugin_Context.php exists within includes
  • $main_file as the plugin's main file should be a protected property
  • Constructor should receive the plugin's main file as a parameter and assign it to $main_file
  • basename() method should return the plugin's name using plugin_basename
  • path() method should return the absolute path of the plugin dir using plugin_dir_path
  • url() method should return the plugin's URL using plugin_dir_url
  • PHPUnit tests covering
    • basename() method returns string and name of the plugin
    • path() method returns string and path of the plugin
    • url() method returns string and URL of the plugin

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