Skip to content

Commit

Permalink
Merge pull request #379 from wp-cli/fix/some-test-duplication
Browse files Browse the repository at this point in the history
Further improve SQLite testing
  • Loading branch information
schlessera authored Nov 10, 2023
2 parents 19f45ab + 8fc9728 commit 0ddd27f
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 173 deletions.
49 changes: 12 additions & 37 deletions features/plugin-auto-updates-disable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,19 @@ 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 all plugins
When I run `wp plugin auto-updates disable --all`
Then STDOUT should be:
"""
Success: Disabled 3 of 3 plugin auto-updates.
"""
And the return code should be 0
When I run `wp plugin list --status=inactive --format=count`
Then save STDOUT as {PLUGIN_COUNT}

@require-wp-5.5 @require-sqlite
Scenario: Disable auto-updates for all plugins
When I run `wp plugin auto-updates disable --all`
Then STDOUT should be:
"""
Success: Disabled 4 of 4 plugin auto-updates.
Success: Disabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates.
"""
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 @@ -63,41 +57,22 @@ 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
@require-wp-5.5
Scenario: Filter when disabling auto-updates for already enabled 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 @require-mysql
Scenario: Filter when enabling auto-updates for already disabled plugins
When I run `wp plugin auto-updates disable hello`
And I run `wp plugin auto-updates disable --all --enabled-only`
Then STDOUT should be:
"""
Success: Disabled 2 of 2 plugin auto-updates.
"""
And the return code should be 0
When I run `wp plugin list --auto_update=on --format=count`
Then save STDOUT as {PLUGIN_COUNT}

@require-wp-5.5 @require-sqlite
Scenario: Filter when enabling auto-updates for already disabled plugins
When I run `wp plugin auto-updates disable hello`
And I run `wp plugin auto-updates disable --all --enabled-only`
When I run `wp plugin auto-updates disable --all --enabled-only`
Then STDOUT should be:
"""
Success: Disabled 3 of 3 plugin auto-updates.
Success: Disabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates.
"""
And the return code should be 0

@require-wp-5.5
Scenario: Filter when enabling auto-updates for already disabled selection of plugins
Scenario: Filter when disabling auto-updates for already disabled selection of plugins
When I run `wp plugin auto-updates disable hello`
And I run `wp plugin auto-updates disable hello duplicate-post --enabled-only`
Then STDOUT should be:
Expand Down
46 changes: 10 additions & 36 deletions features/plugin-auto-updates-enable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,19 @@ 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 all plugins
When I run `wp plugin auto-updates enable --all`
Then STDOUT should be:
"""
Success: Enabled 3 of 3 plugin auto-updates.
"""
And the return code should be 0
When I run `wp plugin list --status=inactive --format=count`
Then save STDOUT as {PLUGIN_COUNT}

@require-wp-5.5 @require-sqlite
Scenario: Enable auto-updates for all plugins
When I run `wp plugin auto-updates enable --all`
Then STDOUT should be:
"""
Success: Enabled 4 of 4 plugin auto-updates.
Success: Enabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates.
"""
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 @@ -62,36 +56,16 @@ 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 @require-mysql
@require-wp-5.5
Scenario: Filter when enabling auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
And I run `wp plugin auto-updates enable --all --disabled-only`
Then STDOUT should be:
"""
Success: Enabled 2 of 2 plugin auto-updates.
"""
And the return code should be 0
And I run `wp plugin list --status=inactive --auto_update=off --format=count`
Then save STDOUT as {PLUGIN_COUNT}

@require-wp-5.5 @require-sqlite
Scenario: Filter when enabling auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
And I run `wp plugin auto-updates enable --all --disabled-only`
When I run `wp plugin auto-updates enable --all --disabled-only`
Then STDOUT should be:
"""
Success: Enabled 3 of 3 plugin auto-updates.
Success: Enabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates.
"""
And the return code should be 0

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
"""
29 changes: 0 additions & 29 deletions features/plugin-delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Feature: Delete WordPress plugins
"""
And the return code should be 0

@require-mysql
Scenario: Delete all installed plugins
When I run `wp plugin delete --all`
Then STDOUT should be:
Expand All @@ -29,24 +28,6 @@ Feature: Delete WordPress plugins
Success: No plugins deleted.
"""

@require-sqlite
Scenario: Delete all installed plugins
When I run `wp plugin delete --all`
Then STDOUT should be:
"""
Deleted 'akismet' plugin.
Deleted 'hello' plugin.
Deleted 'sqlite-database-integration' plugin.
Success: Deleted 3 of 3 plugins.
"""
And the return code should be 0

When I run the previous command again
Then STDOUT should be:
"""
Success: No plugins deleted.
"""

Scenario: Attempting to delete a plugin that doesn't exist
When I try `wp plugin delete edit-flow`
Then STDOUT should be:
Expand All @@ -59,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 @@ -68,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
10 changes: 0 additions & 10 deletions features/plugin-uninstall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -72,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 @@ -81,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
12 changes: 6 additions & 6 deletions features/plugin-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Feature: Update WordPress plugins

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version |
| wordpress-importer | inactive | available | 0.5 |
| name | status | update | version | auto_update |
| wordpress-importer | inactive | available | 0.5 | off |

When I try `wp plugin update akismet --version=0.5.3`
Then STDERR should be:
Expand All @@ -25,16 +25,16 @@ Feature: Update WordPress plugins

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version |
| wordpress-importer | inactive | available | 0.5 |
| name | status | update | version | auto_update |
| wordpress-importer | inactive | available | 0.5 | off |

When I run `wp plugin update wordpress-importer`
Then STDOUT should not be empty

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version |
| wordpress-importer | inactive | none | {UPDATE_VERSION} |
| name | status | update | version | auto_update |
| wordpress-importer | inactive | none | {UPDATE_VERSION} | off |

Scenario: Error when both --minor and --patch are provided
Given a WP install
Expand Down
16 changes: 9 additions & 7 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Feature: Manage WordPress plugins

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version |
| Zombieland | active | none | 0.1.0 |
| name | status | update | version | auto_update |
| Zombieland | active | none | 0.1.0 | off |

When I try `wp plugin uninstall Zombieland`
Then STDERR should be:
Expand Down Expand Up @@ -131,8 +131,8 @@ Feature: Manage WordPress plugins

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version |
| wordpress-importer | active | available | 0.5 |
| name | status | update | version | auto_update |
| wordpress-importer | active | available | 0.5 | off |

When I try `wp plugin update`
Then STDERR should be:
Expand Down Expand Up @@ -397,11 +397,13 @@ Feature: Manage WordPress plugins
Installing Debug Bar List Script & Style Dependencies
"""

# Not running for SQLite because it involves another must-use plugin and a drop-in.
@require-mysql
Scenario: Enable and disable all plugins
Given a WP install

When I run `wp plugin activate --all`
Then STDOUT should be:
Then STDOUT should contain:
"""
Plugin 'akismet' activated.
Plugin 'hello' activated.
Expand Down Expand Up @@ -651,8 +653,8 @@ Feature: Manage WordPress plugins

When I run `wp plugin list`
Then STDOUT should be a table containing rows:
| name | status | update | version |
| hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} |
| name | status | update | version | auto_update |
| hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | off |

When I try `wp plugin update --all`
Then STDERR should be:
Expand Down
Loading

0 comments on commit 0ddd27f

Please sign in to comment.