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.
Description
Create a new
Force_Single_Plugin_Preparationthat will force the plugin to be checks as the only active plugin.Acceptance Criteria
Force_Single_Plugin_Preparationshould be created and exists atincludes/Checker/PreparationsForce_Single_Plugin_Preparationshould extendPreparationinterface$plugin_basenamestring $plugin_basenameparameterprepare()method that does the following$plugin_basenamepropertyoption_active_pluginsdefault_option_active_pluginsfilter_active_plugins()method that accepts an$active_pluginsparameter$this->plugin_basenameexists in the array, and if it does, ensures the$plugin_basenameand plugin checker plugin name are only in the active plugins array.Test Coverage
preparemethod throws and exception if the plugin does not exist in the filesystem.preparemethod prepares the environment by ensuring that theget_option( 'active_plugins' )array includes the$plugin_basename.filter_active_pluginsreturns the$plugin_basenameproperty and plugin checker basename in the array passed when it exist.preparemethod returns a callable cleanup function.