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
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
Plugin_Context.phpexists withinincludes$main_fileas the plugin's main file should be a protected property$main_filebasename()method should return the plugin's name usingplugin_basenamepath()method should return the absolute path of the plugin dir usingplugin_dir_pathurl()method should return the plugin's URL usingplugin_dir_urlbasename()method returns string and name of the pluginpath()method returns string and path of the pluginurl()method returns string and URL of the plugin