Skip to content

Create Force_Single_Plugin_Preparation #58

@jjgrainger

Description

@jjgrainger

Description

Create a new Force_Single_Plugin_Preparation that will force the plugin to be checks as the only active plugin.

Acceptance Criteria

  • Class Force_Single_Plugin_Preparation should be created and exists at includes/Checker/Preparations
  • Class Force_Single_Plugin_Preparation should extend Preparation interface
  • Class should have a protected property $plugin_basename
  • Class constructor accepts a single string $plugin_basename parameter
  • Class contains a prepare() method that does the following
    • Check the plugin folder exists in the plugins directory using the $plugin_basename property
    • If the plugin does not exist, and exception is thrown
    • Ensures the plugin and the plugin check plugin are the only in the active list of plugins using the following filters:
      • option_active_plugins
      • default_option_active_plugins
    • Returns a cleanup function that removes the filters added
  • Class contains a public filter_active_plugins() method that accepts an $active_plugins parameter
    • The method checks if the $this->plugin_basename exists in the array, and if it does, ensures the $plugin_basename and plugin checker plugin name are only in the active plugins array.

Test Coverage

  • Test the prepare method throws and exception if the plugin does not exist in the filesystem.
  • Test the prepare method prepares the environment by ensuring that the get_option( 'active_plugins' ) array includes the $plugin_basename.
  • Test the filter_active_plugins returns the $plugin_basename property and plugin checker basename in the array passed when it exist.
  • Test the prepare method returns a callable cleanup function.

Metadata

Metadata

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions