|
| 1 | +Feature: Check if a WordPress plugin is active |
| 2 | + |
| 3 | + Background: |
| 4 | + Given a WP install |
| 5 | + |
| 6 | + Scenario: Check if an active plugin is active |
| 7 | + When I run `wp plugin activate akismet` |
| 8 | + Then STDOUT should contain: |
| 9 | + """ |
| 10 | + Success: |
| 11 | + """ |
| 12 | + |
| 13 | + When I run `wp plugin is-active akismet` |
| 14 | + Then the return code should be 0 |
| 15 | + |
| 16 | + Scenario: Check if an inactive plugin is not active |
| 17 | + When I run `wp plugin activate akismet` |
| 18 | + Then STDOUT should contain: |
| 19 | + """ |
| 20 | + Success: |
| 21 | + """ |
| 22 | + |
| 23 | + When I run `wp plugin deactivate akismet` |
| 24 | + Then STDOUT should contain: |
| 25 | + """ |
| 26 | + Success: |
| 27 | + """ |
| 28 | + |
| 29 | + When I try `wp plugin is-active akismet` |
| 30 | + Then the return code should be 1 |
| 31 | + |
| 32 | + Scenario: Check if a non-existent plugin is not active |
| 33 | + When I try `wp plugin is-active non-existent-plugin` |
| 34 | + Then the return code should be 1 |
| 35 | + |
| 36 | + Scenario: Warn when plugin is in active_plugins but file does not exist |
| 37 | + When I run `wp plugin activate akismet` |
| 38 | + Then STDOUT should contain: |
| 39 | + """ |
| 40 | + Success: |
| 41 | + """ |
| 42 | + |
| 43 | + When I run `wp plugin is-active akismet` |
| 44 | + Then the return code should be 0 |
| 45 | + |
| 46 | + # Remove the plugin directory |
| 47 | + When I run `wp plugin path akismet --dir` |
| 48 | + Then save STDOUT as {PLUGIN_PATH} |
| 49 | + |
| 50 | + When I run `rm -rf {PLUGIN_PATH}` |
| 51 | + Then the return code should be 0 |
| 52 | + |
| 53 | + # Now the plugin file is gone but still in active_plugins |
| 54 | + When I try `wp plugin is-active akismet` |
| 55 | + Then STDERR should contain: |
| 56 | + """ |
| 57 | + Warning: Plugin 'akismet' is marked as active but the plugin file does not exist. |
| 58 | + """ |
| 59 | + And the return code should be 1 |
| 60 | + |
| 61 | + Scenario: Warn when network-activated plugin is in active_sitewide_plugins but file does not exist |
| 62 | + Given a WP multisite install |
| 63 | + |
| 64 | + When I run `wp plugin activate akismet --network` |
| 65 | + Then STDOUT should contain: |
| 66 | + """ |
| 67 | + Success: |
| 68 | + """ |
| 69 | + |
| 70 | + When I run `wp plugin is-active akismet --network` |
| 71 | + Then the return code should be 0 |
| 72 | + |
| 73 | + # Remove the plugin directory |
| 74 | + When I run `wp plugin path akismet --dir` |
| 75 | + Then save STDOUT as {PLUGIN_PATH} |
| 76 | + |
| 77 | + When I run `rm -rf {PLUGIN_PATH}` |
| 78 | + Then the return code should be 0 |
| 79 | + |
| 80 | + # Now the plugin file is gone but still in active_sitewide_plugins |
| 81 | + When I try `wp plugin is-active akismet --network` |
| 82 | + Then STDERR should contain: |
| 83 | + """ |
| 84 | + Warning: Plugin 'akismet' is marked as active but the plugin file does not exist. |
| 85 | + """ |
| 86 | + And the return code should be 1 |
0 commit comments