extension-command/features/plugin-activate.feature
Nathaniel Taintor 79d5d3c0f7 Fix plugin-activate feature test scenario
A test for "plugin activate" shouldn't start with the plugins already
activated. This changes the scenario to start with the default WP
install, install an additional plugin, and then hide it using a filter.
2017-08-18 14:23:59 -07:00

64 lines
1.8 KiB
Gherkin

Feature: Activate WordPress plugins
Background:
Given a WP install
Scenario: Activate a plugin that's already installed
When I run `wp plugin activate akismet`
Then STDOUT should be:
"""
Plugin 'akismet' activated.
Success: Activated 1 of 1 plugins.
"""
And the return code should be 0
Scenario: Attempt to activate a plugin that's not installed
When I try `wp plugin activate edit-flow`
Then STDERR should be:
"""
Warning: The 'edit-flow' plugin could not be found.
Error: No plugins activated.
"""
And the return code should be 1
When I try `wp plugin activate akismet hello edit-flow`
Then STDERR should be:
"""
Warning: The 'edit-flow' plugin could not be found.
Error: Only activated 2 of 3 plugins.
"""
And STDOUT should be:
"""
Plugin 'akismet' activated.
Plugin 'hello' activated.
"""
And the return code should be 1
Scenario: Activate all when one plugin is hidden by "all_plugins" filter
Given I run `wp plugin install query-monitor`
And a wp-content/mu-plugins/hide-qm-plugin.php file:
"""
<?php
/**
* Plugin Name: Hide Query Monitor on Production
* Description: Hides the Query Monitor plugin on production sites
* Author: WP-CLI tests
*/
add_filter( 'all_plugins', function( $all_plugins ) {
unset( $all_plugins['query-monitor/query-monitor.php'] );
return $all_plugins;
} );
"""
When I run `wp plugin activate --all`
Then STDOUT should contain:
"""
Plugin 'akismet' activated.
Plugin 'hello' activated.
"""
And STDOUT should not contain:
"""
Plugin 'query-monitor' activated.
"""