Skip to content

Commit

Permalink
Simplify tests all over again
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Nov 10, 2023
1 parent 70efcdc commit 72ee662
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 164 deletions.
7 changes: 0 additions & 7 deletions features/plugin-activate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ Feature: Activate WordPress plugins
"""
And STDERR should be empty

# Disabled for SQLite because this tests a scenario with an empty plugins directory,
# so the SQLite integration plugin would be missing.
@require-mysql
Scenario: Not giving a slug on activate should throw an error unless --all given
When I try `wp plugin activate`
Then the return code should be 1
Expand Down Expand Up @@ -143,10 +140,6 @@ Feature: Activate WordPress plugins
"""
And the return code should be 0

# Disabled for SQLite because the SQLite plugin attempts to do a redirect,
# which would cause the "Success" check to fail.
# See https://github.com/WordPress/sqlite-database-integration/issues/49
@require-mysql
Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin activate --all --exclude=missing-plugin`
Expand Down
15 changes: 1 addition & 14 deletions features/plugin-auto-updates-disable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Feature: Disable auto-updates for WordPress plugins
"""
And the return code should be 0

@require-wp-5.5 @require-mysql
@require-wp-5.5
Scenario: Disable auto-updates for already disabled plugins
When I run `wp plugin auto-updates disable hello`
And I try `wp plugin auto-updates disable --all`
Expand All @@ -57,19 +57,6 @@ Feature: Disable auto-updates for WordPress plugins
Error: Only disabled 2 of 3 plugin auto-updates.
"""

@require-wp-5.5 @require-sqlite
Scenario: Disable auto-updates for already disabled plugins
When I run `wp plugin auto-updates disable hello`
And I try `wp plugin auto-updates disable --all`
Then STDERR should contain:
"""
Warning: Auto-updates already disabled for plugin hello.
"""
And STDERR should contain:
"""
Error: Only disabled 3 of 4 plugin auto-updates.
"""

@require-wp-5.5
Scenario: Filter when disabling auto-updates for already enabled plugins
When I run `wp plugin auto-updates disable hello`
Expand Down
15 changes: 1 addition & 14 deletions features/plugin-auto-updates-enable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Feature: Enable auto-updates for WordPress plugins
"""
And the return code should be 0

@require-wp-5.5 @require-mysql
@require-wp-5.5
Scenario: Enable auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
And I try `wp plugin auto-updates enable --all`
Expand All @@ -56,19 +56,6 @@ Feature: Enable auto-updates for WordPress plugins
Error: Only enabled 2 of 3 plugin auto-updates.
"""

@require-wp-5.5 @require-sqlite
Scenario: Enable auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
And I try `wp plugin auto-updates enable --all`
Then STDERR should contain:
"""
Warning: Auto-updates already enabled for plugin hello.
"""
And STDERR should contain:
"""
Error: Only enabled 3 of 4 plugin auto-updates.
"""

@require-wp-5.5
Scenario: Filter when enabling auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
Expand Down
40 changes: 2 additions & 38 deletions features/plugin-auto-updates-status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,14 @@ Feature: Show the status of auto-updates for WordPress plugins
Error: --enabled-only and --disabled-only are mutually exclusive and cannot be used at the same time.
"""

@require-wp-5.5 @require-mysql
Scenario: The fields can be shown individually
Given I run `wp plugin auto-updates enable hello`

When I run `wp plugin auto-updates status --all --disabled-only --field=name`
Then STDOUT should be:
"""
akismet
duplicate-post
"""

When I run `wp plugin auto-updates status hello --field=status`
Then STDOUT should be:
"""
enabled
"""

@require-wp-5.5 @require-sqlite
@require-wp-5.5
Scenario: The fields can be shown individually
Given I run `wp plugin auto-updates enable hello`

When I run `wp plugin auto-updates status --all --disabled-only --field=name`
Then STDOUT should be:
"""
akismet
sqlite-database-integration
duplicate-post
"""

Expand All @@ -116,7 +98,7 @@ Feature: Show the status of auto-updates for WordPress plugins
enabled
"""

@require-wp-5.5 @require-mysql
@require-wp-5.5
Scenario: Formatting options work
When I run `wp plugin auto-updates status --all --format=json`
Then STDOUT should be:
Expand All @@ -132,21 +114,3 @@ Feature: Show the status of auto-updates for WordPress plugins
hello,disabled
duplicate-post,disabled
"""

@require-wp-5.5 @require-sqlite
Scenario: Formatting options work
When I run `wp plugin auto-updates status --all --format=json`
Then STDOUT should be:
"""
[{"name":"akismet","status":"disabled"},{"name":"hello","status":"disabled"},{"name":"sqlite-database-integration","status":"disabled"},{"name":"duplicate-post","status":"disabled"}]
"""

When I run `wp plugin auto-updates status --all --format=csv`
Then STDOUT should be:
"""
name,status
akismet,disabled
hello,disabled
sqlite-database-integration,disabled
duplicate-post,disabled
"""
14 changes: 0 additions & 14 deletions features/plugin-deactivate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ Feature: Deactivate WordPress plugins
Plugin 'akismet' deactivated.
"""

# Disabled for SQLite because this tests a scenario with an empty plugins directory,
# so the SQLite integration plugin would be missing.
@require-mysql
Scenario: Not giving a slug on deactivate should throw an error unless --all given
When I try `wp plugin deactivate`
Then the return code should be 1
Expand All @@ -80,7 +77,6 @@ Feature: Deactivate WordPress plugins
Success: No plugins deactivated.
"""

@require-mysql
Scenario: Adding --exclude with plugin deactivate --all should exclude the plugins specified via --exclude
When I try `wp plugin deactivate --all --exclude=hello`
Then STDOUT should be:
Expand All @@ -90,16 +86,6 @@ Feature: Deactivate WordPress plugins
"""
And the return code should be 0

@require-sqlite
Scenario: Adding --exclude with plugin deactivate --all should exclude the plugins specified via --exclude
When I try `wp plugin deactivate --all --exclude=hello`
Then STDOUT should be:
"""
Plugin 'akismet' deactivated.
Success: Deactivated 1 of 2 plugins.
"""
And the return code should be 0

Scenario: Adding --exclude with plugin deactivate should throw an error unless --all given
When I try `wp plugin deactivate --exclude=hello`
Then the return code should be 1
Expand Down
13 changes: 0 additions & 13 deletions features/plugin-delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Feature: Delete WordPress plugins
"""
And the return code should be 0

# Disabled for SQLite because this tests a scenario with an empty plugins directory,
# so the SQLite integration plugin would be missing.
@require-mysql
Scenario: Delete all installed plugins
When I run `wp plugin delete --all`
Then STDOUT should be:
Expand Down Expand Up @@ -43,7 +40,6 @@ Feature: Delete WordPress plugins
"""
And the return code should be 0

@require-mysql
Scenario: Excluding a plugin from deletion when using --all switch
When I try `wp plugin delete --all --exclude=akismet,hello`
Then STDOUT should be:
Expand All @@ -52,15 +48,6 @@ Feature: Delete WordPress plugins
"""
And the return code should be 0

@require-sqlite
Scenario: Excluding a plugin from deletion when using --all switch
When I try `wp plugin delete --all --exclude=akismet,hello,sqlite-database-integration`
Then STDOUT should be:
"""
Success: No plugins deleted.
"""
And the return code should be 0

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin delete --all --exclude=missing-plugin`
Expand Down
28 changes: 0 additions & 28 deletions features/plugin-uninstall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Feature: Uninstall a WordPress plugin
"""
And the return code should be 1

@require-mysql
Scenario: Uninstall all installed plugins
When I run `wp plugin uninstall --all`
Then STDOUT should be:
Expand All @@ -51,23 +50,6 @@ Feature: Uninstall a WordPress plugin
Success: No plugins uninstalled.
"""

# Not running the previous command again in this test
# because the SQLite integration plugin is missing after the first run.
@require-sqlite
Scenario: Uninstall all installed plugins
When I run `wp plugin uninstall --all`
Then STDOUT should be:
"""
Uninstalled and deleted 'akismet' plugin.
Uninstalled and deleted 'hello' plugin.
Uninstalled and deleted 'sqlite-database-integration' plugin.
Success: Uninstalled 3 of 3 plugins.
"""
And the return code should be 0

# Disabled for SQLite because this test uninstalls all plugins,
# including the SQLite integration plugin.
@require-mysql
Scenario: Uninstall all installed plugins when one or more activated
When I run `wp plugin activate --all`
Then STDOUT should contain:
Expand All @@ -90,7 +72,6 @@ Feature: Uninstall a WordPress plugin
Success: Uninstalled 2 of 2 plugins.
"""

@require-mysql
Scenario: Excluding a plugin from uninstallation when using --all switch
When I try `wp plugin uninstall --all --exclude=akismet,hello`
Then STDOUT should be:
Expand All @@ -99,15 +80,6 @@ Feature: Uninstall a WordPress plugin
"""
And the return code should be 0

@require-sqlite
Scenario: Excluding a plugin from uninstallation when using --all switch
When I try `wp plugin uninstall --all --exclude=akismet,hello,sqlite-database-integration`
Then STDOUT should be:
"""
Success: No plugins uninstalled.
"""
And the return code should be 0

Scenario: Excluding a missing plugin should not throw an error
Given a WP install
And I run `wp plugin uninstall --all --exclude=missing-plugin`
Expand Down
4 changes: 1 addition & 3 deletions features/plugin-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ Feature: Update WordPress plugins
2.6.1
"""

# Disabled for SQLite because this tests a scenario with an empty plugins directory,
# so the SQLite integration plugin would be missing.
@require-wp-5.2 @require-mysql
@require-wp-5.2
Scenario: Not giving a slug on update should throw an error unless --all given
Given a WP install
And I run `wp plugin path`
Expand Down
34 changes: 1 addition & 33 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ Feature: Manage WordPress plugins
"""
And the return code should be 0

@require-mysql
Scenario: List plugins
Given a WP install

Expand All @@ -318,30 +317,6 @@ Feature: Manage WordPress plugins
Automattic
"""

@require-sqlite
Scenario: List plugins
Given a WP install

When I run `wp plugin activate akismet hello`
Then STDOUT should not be empty

When I run `wp plugin list --status=inactive --field=name`
Then STDOUT should contain:
"""
sqlite-database-integration
"""

When I run `wp plugin list --status=active --fields=name,status,file`
Then STDOUT should be a table containing rows:
| name | status | file |
| akismet | active | akismet/akismet.php |

When I run `wp plugin list --status=active --field=author`
Then STDOUT should contain:
"""
Automattic
"""

Scenario: List plugin by multiple statuses
Given a WP multisite install
And a wp-content/plugins/network-only.php file:
Expand Down Expand Up @@ -398,9 +373,6 @@ Feature: Manage WordPress plugins
| name | status | update |
| wordpress-importer | inactive | none |

# Disabled for SQLite because this tests a scenario with an empty plugins directory,
# so the SQLite integration plugin would be missing.
@require-mysql
Scenario: Install a plugin when directory doesn't yet exist
Given a WP install

Expand All @@ -425,8 +397,6 @@ Feature: Manage WordPress plugins
Installing Debug Bar List Script & Style Dependencies
"""

# Disabled for SQLite because this tests a specific list of plugins.
@require-mysql
Scenario: Enable and disable all plugins
Given a WP install

Expand Down Expand Up @@ -649,9 +619,7 @@ Feature: Manage WordPress plugins
| name | title | description | file |
| db-error.php | | Custom database error message. | db-error.php |

# Disabled for SQLite because this test uninstalls all plugins,
# including the SQLite integration plugin.
@require-wp-4.0 @require-mysql
@require-wp-4.0
Scenario: Validate installed plugin's version.
Given a WP installation
And I run `wp plugin uninstall --all`
Expand Down

0 comments on commit 72ee662

Please sign in to comment.