diff --git a/codeception.dist.yml b/codeception.dist.yml index 2ade96668..7fc117f9d 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -29,6 +29,9 @@ extensions: 'tests/_data/themes/dummy': '%WORDPRESS_ROOT_DIR%/wp-content/themes/dummy' 'tests/_data/themes/isolated': '%WORDPRESS_ROOT_DIR%/wp-content/themes/isolated' 'tests/_data/plugins/mu-plugin-1': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/mu-plugin-1' + 'tests/_data/plugins/doing-it-right': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/doing-it-right' + 'tests/_data/plugins/doing-it-wrong-1': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/doing-it-wrong-1' + 'tests/_data/plugins/doing-it-wrong-2': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/doing-it-wrong-2' 'tests/_data/plugins/test': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/test' 'tests/_data/plugins/isolated-test-plugin': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/isolated-test-plugin' 'tests/_data/plugins/isolated-test-plugin-two': '%WORDPRESS_ROOT_DIR%/wp-content/plugins/isolated-test-plugin-two' diff --git a/src/Codeception/Module/WPLoader.php b/src/Codeception/Module/WPLoader.php index 13566b098..047df309c 100644 --- a/src/Codeception/Module/WPLoader.php +++ b/src/Codeception/Module/WPLoader.php @@ -138,6 +138,10 @@ class WPLoader extends Module * activated calling the `activate_{$plugin}` before any test case runs and * after mu-plugins have been loaded; these should be defined in the * `folder/plugin-file.php` format. + * activatePlugins - array, def. `[]`, a list of plugins that should be + * silently activated calling the `activate_{$plugin}` before any test case runs and + * after mu-plugins have been loaded; these should be defined in the + * `folder/plugin-file.php` format. * bootstrapActions - array, def. `[]`, a list of actions that should be * called after before any test case runs. * skipPluggables - bool, def. `false`, if set to `true` will skip the @@ -148,27 +152,28 @@ class WPLoader extends Module */ protected $config = [ - 'loadOnly' => false, - 'isolatedInstall' => true, - 'installationTableHandling' => 'empty', - 'wpDebug' => true, - 'multisite' => false, - 'skipPluggables' => false, - 'dbCharset' => 'utf8', - 'dbCollate' => '', - 'tablePrefix' => 'wptests_', - 'domain' => 'example.org', - 'adminEmail' => 'admin@example.org', - 'title' => 'Test Blog', - 'phpBinary' => 'php', - 'language' => '', - 'configFile' => '', - 'contentFolder' => '', - 'pluginsFolder' => '', - 'plugins' => '', - 'activatePlugins' => '', - 'bootstrapActions' => '', - 'theme' => '', + 'loadOnly' => false, + 'isolatedInstall' => true, + 'installationTableHandling' => 'empty', + 'wpDebug' => true, + 'multisite' => false, + 'skipPluggables' => false, + 'dbCharset' => 'utf8', + 'dbCollate' => '', + 'tablePrefix' => 'wptests_', + 'domain' => 'example.org', + 'adminEmail' => 'admin@example.org', + 'title' => 'Test Blog', + 'phpBinary' => 'php', + 'language' => '', + 'configFile' => '', + 'contentFolder' => '', + 'pluginsFolder' => '', + 'plugins' => [], + 'activatePlugins' => [], + 'activatePluginsSilently' => [], + 'bootstrapActions' => '', + 'theme' => '', ]; /** @@ -1116,10 +1121,13 @@ public function getContentFolder($path = '') */ protected function getInstallationConfiguration() { - return new Configuration([ - 'tablesHandling' => isset($this->config['installationTableHandling']) ? - $this->config['installationTableHandling'] - : 'empty' - ]); + return new Configuration( [ + 'tablesHandling' => isset( $this->config['installationTableHandling'] ) ? + $this->config['installationTableHandling'] + : 'empty', + 'activatePluginsSilently' => isset( $this->config['activatePluginsSilently'] ) ? + (array) $this->config['activatePluginsSilently'] + : [] + ] ); } } diff --git a/src/includes/bootstrap.php b/src/includes/bootstrap.php index e9b8ab2fa..58646812e 100644 --- a/src/includes/bootstrap.php +++ b/src/includes/bootstrap.php @@ -114,6 +114,7 @@ 'WPLANG' => WPLANG, ], 'tablesHandling' => $installationConfiguration->get('tablesHandling','empty'), + 'activatePluginsSilently' => $installationConfiguration->get('activatePluginsSilently', []), ]; $dirConstants = [ diff --git a/src/includes/isolated-install.php b/src/includes/isolated-install.php index aa9ab553d..0d4d7c070 100644 --- a/src/includes/isolated-install.php +++ b/src/includes/isolated-install.php @@ -192,9 +192,13 @@ $current_site->blog_id = 1; } +$activatePluginsSilently = isset( $configuration['activatePluginsSilently'] ) ? + $configuration['activatePluginsSilently'] + : []; + // finally activate the plugins that should be activated if (!empty($activePlugins)) { - $activePlugins = array_unique($activePlugins); + $activePlugins = array_values( array_unique( array_merge( $activePlugins, $activatePluginsSilently ) ) ); if ($multisite) { require(ABSPATH . WPINC . '/class-wp-site-query.php'); @@ -204,8 +208,9 @@ } foreach ($activePlugins as $plugin) { + $silent = in_array($plugin, $activatePluginsSilently,true); printf("\n%sctivating plugin [%s]...", $multisite ? 'Network a' : 'A', $plugin); - $activated = activate_plugin($plugin, null, $multisite, false); + $activated = activate_plugin($plugin, null, $multisite, $silent); if (is_wp_error($activated)) { echo $activated->get_error_message(); diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 0e7e3ed85..218a63156 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,15 +1,47 @@ getSuite()->getName(); +// +// if ( $suiteName !== 'wploader_plugin_silent_activation' ) { +// return; +// } +// +// $wpRootDir = realpath( getenv( 'WORDPRESS_ROOT_DIR' ) ); +// +// if ( ! is_dir( $wpRootDir ) ) { +// throw new \RuntimeException( "The WORDPRESS_ROOT_DIR is not a valid directory." ); +// } +// +// $wpRootDir = rtrim( $wpRootDir, '/\\' ); +// +// foreach ( +// [ +// codecept_data_dir( 'plugins/doing-it-wrong-1' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-1', +// codecept_data_dir( 'plugins/doing-it-wrong-2' ) => $wpRootDir . '/wp-content/plugins/doing-it-wrong-2', +// ] as $source => $destination +// ) { +// if ( ! copy( +// $source, +// $destination +// ) ) { +// throw new \RuntimeException( "Could not copy the plugin to the WordPress plugins directory." ); +// } +// } +//} ); diff --git a/tests/_data/plugins/doing-it-right/plugin.php b/tests/_data/plugins/doing-it-right/plugin.php new file mode 100644 index 000000000..1dae79ca4 --- /dev/null +++ b/tests/_data/plugins/doing-it-right/plugin.php @@ -0,0 +1,13 @@ +getPluginsFolder(); + * $hello = $this->getPluginsFolder('hello.php'); + * ``` + * + * @param string $path A relative path to append to te plugins directory absolute path. + * + * @return string The absolute path to the `pluginsFolder` path or the same with a relative path appended if `$path` + * is provided. + * + * @throws ModuleConfigException If the path to the plugins folder does not exist. + * @see \Codeception\Module\WPLoader::getPluginsFolder() + */ + public function getPluginsFolder($path = "") { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getPluginsFolder', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Accessor method to get the object storing the factories for things. + * This methods gives access to the same factories provided by the + * [Core test suite](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/). + * + * @return FactoryStore A factory store, proxy to get hold of the Core suite object + * factories. + * + * @example + * ```php + * $postId = $I->factory()->post->create(); + * $userId = $I->factory()->user->create(['role' => 'administrator']); + * ``` + * + * @link https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/ + * @see \Codeception\Module\WPLoader::factory() + */ + public function factory() { + return $this->getScenario()->runStep(new \Codeception\Step\Action('factory', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Returns the absolute path to the WordPress content directory. + * + * @example + * ```php + * $content = $this->getContentFolder(); + * $themes = $this->getContentFolder('themes'); + * $twentytwenty = $this->getContentFolder('themes/twentytwenty'); + * ``` + * + * @param string $path An optional path to append to the content directory absolute path. + * + * @return string The content directory absolute path, or a path in it. + * + * @throws ModuleConfigException If the path to the content directory cannot be resolved. + * @see \Codeception\Module\WPLoader::getContentFolder() + */ + public function getContentFolder($path = "") { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getContentFolder', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Starts the debug of all WordPress filters and actions. + * + * The method hook on `all` filters and actions to debug their value. + * + * @example + * ```php + * // Start debugging all WordPress filters and action final and initial values. + * $this->startWpFiltersDebug(); + * + * // Run some code firing filters and debug them. + * + * // Stop debugging all WordPress filters and action final and initial values. + * $this->stopWpFiltersDebug(); + * ``` + * + * @param callable|null $format A callback function to format the arguments debug output; the callback will receive + * the array of arguments as input. + * + * @return void + * @see \Codeception\Module\WPLoader::startWpFiltersDebug() + */ + public function startWpFiltersDebug(?callable $format = NULL) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('startWpFiltersDebug', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Stops the debug of all WordPress filters and actions. + * + * @example + * ```php + * // Start debugging all WordPress filters and action final and initial values. + * $this->startWpFiltersDebug(); + * + * // Run some code firing filters and debug them. + * + * // Stop debugging all WordPress filters and action final and initial values. + * $this->stopWpFiltersDebug(); + * ``` + * + * @return void + * @see \Codeception\Module\WPLoader::stopWpFiltersDebug() + */ + public function stopWpFiltersDebug() { + return $this->getScenario()->runStep(new \Codeception\Step\Action('stopWpFiltersDebug', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Debugs a single WordPress filter initial call using Codeception debug functions. + * + * The output will show following the selected output verbosity (`--debug` and `-vvv` CLI options). + * + * @example + * ```php + * // Start debugging all WordPress filters initial value. + * add_filter('all', [$this,'debugWpFilterInitial']); + * + * // Run some code firing filters and debug them. + * + * // Stop debugging all WordPress filters initial value. + * remove_filter('all', [$this,'debugWpFilterInitial']); + * ``` + * + * @param mixed ...$args The filter call arguments. + * + * @return mixed The filter input value, unchanged. + * @see \Codeception\Module\WPLoader::debugWpFilterInitial() + */ + public function debugWpFilterInitial($args = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('debugWpFilterInitial', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Debugs a single WordPress filter final call using Codeception debug functions. + * + * The output will show following the selected output verbosity (`--debug` and `-vvv` CLI options). + * + * @example + * ```php + * // Start debugging all WordPress filters final value. + * add_filter('all', [$this,'debugWpFilterFinal']); + * + * // Run some code firing filters and debug them. + * + * // Stop debugging all WordPress filters final value. + * remove_filter('all', [$this,'debugWpFilterFinal']); + * ``` + * + * @param mixed ...$args The filter call arguments. + * + * @return mixed The filter input value, unchanged. + * @see \Codeception\Module\WPLoader::debugWpFilterFinal() + */ + public function debugWpFilterFinal($args = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('debugWpFilterFinal', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Debugs a single WordPress action initial call using Codeception debug functions. + * + * The output will show following the selected output verbosity (`--debug` and `-vvv` CLI options). + * + * @example + * ```php + * // Start debugging all WordPress actions initial value. + * add_action('all', [$this,'debugWpActionInitial']); + * + * // Run some code firing actions and debug them. + * + * // Stop debugging all WordPress actions initial value. + * remove_action('all', [$this,'debugWpActionInitial']); + * ``` + * + * @param mixed ...$args The action call arguments. + * + * @return void + * @see \Codeception\Module\WPLoader::debugWpActionInitial() + */ + public function debugWpActionInitial($args = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('debugWpActionInitial', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Debugs a single WordPress action final call using Codeception debug functions. + * + * The output will show following the selected output verbosity (`--debug` and `-vvv` CLI options). + * + * @example + * ```php + * // Start debugging all WordPress actions final value. + * add_action('all', [$this,'debugWpActionFinal']); + * + * // Run some code firing actions and debug them. + * + * // Stop debugging all WordPress actions final value. + * remove_action('all', [$this,'debugWpActionFinal']); + * ``` + * + * @param mixed ...$args The action call arguments. + * + * @return void + * @see \Codeception\Module\WPLoader::debugWpActionFinal() + */ + public function debugWpActionFinal($args = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('debugWpActionFinal', func_get_args())); + } +} diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_multisite_with_missing_blogs_entry_for_site__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_multisite_with_missing_blogs_entry_for_site__0.snapshot.json index 927792c61..097a74cfd 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_multisite_with_missing_blogs_entry_for_site__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_multisite_with_missing_blogs_entry_for_site__0.snapshot.json @@ -32,6 +32,9 @@ "Must-use plugins health-check:": "mu-plugins directory (wp-content/mu-plugins) does not exist.", "Plugins health-check:": { "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_available_wpdb_global__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_available_wpdb_global__0.snapshot.json index 867c3ac5a..2bbb81b42 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_available_wpdb_global__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_available_wpdb_global__0.snapshot.json @@ -33,6 +33,9 @@ "Plugins health-check:": { "Active plugin [airplane-mode/airplane-mode.php]": "file [wp-content/plugins/airplane-mode/airplane-mode.php] does not exist.", "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_diff_set_of_tables_specified_from_wpdb_global__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_diff_set_of_tables_specified_from_wpdb_global__0.snapshot.json index dc9f464b8..5a539f733 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_diff_set_of_tables_specified_from_wpdb_global__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_diff_set_of_tables_specified_from_wpdb_global__0.snapshot.json @@ -33,6 +33,9 @@ "Plugins health-check:": { "Active plugin [airplane-mode/airplane-mode.php]": "file [wp-content/plugins/airplane-mode/airplane-mode.php] does not exist.", "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_empty_and_missing_template_and_stylesheet_files__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_empty_and_missing_template_and_stylesheet_files__0.snapshot.json index dcf14bb64..d7b1e5272 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_empty_and_missing_template_and_stylesheet_files__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_empty_and_missing_template_and_stylesheet_files__0.snapshot.json @@ -34,6 +34,9 @@ "Active plugin [one/one.php]": "file [wp-content/plugins/one/one.php] does not exist.", "Active plugin [two/two.php]": "file [wp-content/plugins/two/two.php] does not exist.", "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_inactive_plugins__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_inactive_plugins__0.snapshot.json index 79b35a6d0..2fccaab9c 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_inactive_plugins__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_inactive_plugins__0.snapshot.json @@ -31,6 +31,9 @@ }, "Must-use plugins health-check:": "mu-plugins directory (wp-content/mu-plugins) does not exist.", "Plugins health-check:": { + "Inactive plugin [doing-it-right]": "../../tests/_data/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "../../tests/_data/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "../../tests/_data/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "../../tests/_data/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "../../tests/_data/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "../../tests/_data/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_missing_siteurl_option__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_missing_siteurl_option__0.snapshot.json index 6fce6a284..41fcdae51 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_missing_siteurl_option__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_missing_siteurl_option__0.snapshot.json @@ -32,6 +32,9 @@ "Must-use plugins health-check:": "mu-plugins directory (wp-content/mu-plugins) does not exist.", "Plugins health-check:": { "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_mu_plugins_dir_constant_set__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_mu_plugins_dir_constant_set__0.snapshot.json index 94cf71efc..4448e870f 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_mu_plugins_dir_constant_set__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_mu_plugins_dir_constant_set__0.snapshot.json @@ -33,6 +33,9 @@ "Plugins health-check:": { "Active plugin [airplane-mode/airplane-mode.php]": "file [wp-content/plugins/airplane-mode/airplane-mode.php] does not exist.", "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_no_results_in_blogs_for_blog_domain__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_no_results_in_blogs_for_blog_domain__0.snapshot.json index 54054dbc2..936a2d86b 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_no_results_in_blogs_for_blog_domain__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_no_results_in_blogs_for_blog_domain__0.snapshot.json @@ -32,6 +32,9 @@ "Must-use plugins health-check:": "mu-plugins directory (wp-content/mu-plugins) does not exist.", "Plugins health-check:": { "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_installation__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_installation__0.snapshot.json index 7013031a9..28450ae6b 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_installation__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_installation__0.snapshot.json @@ -33,6 +33,9 @@ "Plugins health-check:": { "Active plugin [airplane-mode/airplane-mode.php]": "file [wp-content/plugins/airplane-mode/airplane-mode.php] does not exist.", "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdir_installation__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdir_installation__0.snapshot.json index ace79169f..a9e64499c 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdir_installation__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdir_installation__0.snapshot.json @@ -32,6 +32,9 @@ "Must-use plugins health-check:": "mu-plugins directory (wp-content/mu-plugins) does not exist.", "Plugins health-check:": { "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdomain_installation__0.snapshot.json b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdomain_installation__0.snapshot.json index b35bbd620..d48719d01 100644 --- a/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdomain_installation__0.snapshot.json +++ b/tests/dbunit/tad/WPBrowser/Module/Support/__snapshots__/WPHealthcheckTest__test_with_working_multisite_subdomain_installation__0.snapshot.json @@ -32,6 +32,9 @@ "Must-use plugins health-check:": "mu-plugins directory (wp-content/mu-plugins) does not exist.", "Plugins health-check:": { "Inactive plugin [akismet]": "wp-content/plugins/akismet", + "Inactive plugin [doing-it-right]": "wp-content/plugins/doing-it-right", + "Inactive plugin [doing-it-wrong-1]": "wp-content/plugins/doing-it-wrong-1", + "Inactive plugin [doing-it-wrong-2]": "wp-content/plugins/doing-it-wrong-2", "Inactive plugin [isolated-test-plugin-two]": "wp-content/plugins/isolated-test-plugin-two", "Inactive plugin [isolated-test-plugin]": "wp-content/plugins/isolated-test-plugin", "Inactive plugin [mu-plugin-1]": "wp-content/plugins/mu-plugin-1", diff --git a/tests/wploader_plugin_silent_activation.suite.dist.yml b/tests/wploader_plugin_silent_activation.suite.dist.yml new file mode 100644 index 000000000..57ab670a0 --- /dev/null +++ b/tests/wploader_plugin_silent_activation.suite.dist.yml @@ -0,0 +1,30 @@ +actor: Wploader_plugin_silent_activationTester +modules: + enabled: + - WPLoader + config: + WPLoader: + wpRootFolder: '%WORDPRESS_ROOT_DIR%' + dbName: '%WORDPRESS_DB_NAME%' + dbHost: '%WORDPRESS_DB_HOST%' + dbUser: '%WORDPRESS_DB_USER%' + dbPassword: '%WORDPRESS_DB_PASSWORD%' + wpDebug: true + tablePrefix: '%WORDPRESS_TABLE_PREFIX%' + domain: '%WP_DOMAIN%' + adminEmail: 'admin@%WP_DOMAIN%' + title: Test + configFile: '' + theme: dummy + plugins: + - doing-it-right/plugin.php + - doing-it-wrong-1/plugin.php + - doing-it-wrong-2/plugin.php + activateplugins: + - doing-it-right/plugin.php + - doing-it-wrong-1/plugin.php + activatePluginsSilently: + - doing-it-wrong-1/plugin.php + - doing-it-wrong-2/plugin.php + installationTableHandling: drop + booststrapActions: [] diff --git a/tests/wploader_plugin_silent_activation/DoingItRightTest.php b/tests/wploader_plugin_silent_activation/DoingItRightTest.php new file mode 100644 index 000000000..bab65c350 --- /dev/null +++ b/tests/wploader_plugin_silent_activation/DoingItRightTest.php @@ -0,0 +1,23 @@ +assertTrue( is_plugin_active( 'doing-it-right/plugin.php' ) ); + $this->assertEquals( 'activated', get_option( 'doing_it_right_activation' ) ); + } + + /** + * It should correctly load the plugin + * + * @test + */ + public function should_correctly_load_the_plugin() { + global $doing_it_right_plugin_loaded; + $this->assertTrue( $doing_it_right_plugin_loaded ); + } +} diff --git a/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php b/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php new file mode 100644 index 000000000..671d64e67 --- /dev/null +++ b/tests/wploader_plugin_silent_activation/DoingItWrongPluginOneTest.php @@ -0,0 +1,31 @@ +assertTrue( is_plugin_active( 'doing-it-wrong-1/plugin.php' ) ); + } + + /** + * It should not have set the option during the plugin activation + * + * @test + */ + public function should_have_not_set_the_option_during_the_plugin_activation(){ + $this->assertEquals( '', get_option( 'doing_it_wrong_1_activation' ) ); + } + + /** + * It should correctly load the plugin + * + * @test + */ + public function should_correctly_load_the_plugin() { + global $doing_it_wrong_1_plugin_loaded; + $this->assertTrue( $doing_it_wrong_1_plugin_loaded ); + } +} diff --git a/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php b/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php new file mode 100644 index 000000000..bc4e0dc5b --- /dev/null +++ b/tests/wploader_plugin_silent_activation/DoingItWrongPluginTwoTest.php @@ -0,0 +1,31 @@ +assertTrue( is_plugin_active( 'doing-it-wrong-2/plugin.php' ) ); + } + + /** + * It should have not set the option during the plugin activation + * + * @test + */ + public function should_have_set_not_the_option_during_the_plugin_activation() { + $this->assertEquals( '', get_option( 'doing_it_wrong_2_activation' ) ); + } + + /** + * It should correctly load the plugin + * + * @test + */ + public function should_correctly_load_the_plugin() { + global $doing_it_wrong_2_plugin_loaded; + $this->assertTrue( $doing_it_wrong_2_plugin_loaded ); + } +}