|
| 1 | +Feature: Download WordPress.org extensions without loading WordPress |
| 2 | + |
| 3 | + Scenario: Downloading a plugin package works before WordPress is loaded |
| 4 | + Given an empty directory |
| 5 | + |
| 6 | + When I run `wp plugin download debug-bar` |
| 7 | + Then STDOUT should contain: |
| 8 | + """ |
| 9 | + Downloading debug-bar |
| 10 | + """ |
| 11 | + And STDOUT should contain: |
| 12 | + """ |
| 13 | + Success: Downloaded plugin package to |
| 14 | + """ |
| 15 | + And save STDOUT 'Success: Downloaded plugin package to (.+)' as {DOWNLOADED_PLUGIN} |
| 16 | + And the {DOWNLOADED_PLUGIN} file should exist |
| 17 | + And STDERR should be empty |
| 18 | + |
| 19 | + Scenario: Downloading a plugin package to a custom path |
| 20 | + Given an empty directory |
| 21 | + |
| 22 | + When I run `wp plugin download debug-bar --target-path=/tmp/wp-cli-download-test-plugin` |
| 23 | + Then STDOUT should contain: |
| 24 | + """ |
| 25 | + Success: Downloaded plugin package to |
| 26 | + """ |
| 27 | + And save STDOUT 'Success: Downloaded plugin package to (.+)' as {DOWNLOADED_PLUGIN} |
| 28 | + And the {DOWNLOADED_PLUGIN} file should exist |
| 29 | + And STDERR should be empty |
| 30 | + |
| 31 | + Scenario: Downloading a specific version of a plugin |
| 32 | + Given an empty directory |
| 33 | + |
| 34 | + When I run `wp plugin download debug-bar --version=1.1` |
| 35 | + Then STDOUT should contain: |
| 36 | + """ |
| 37 | + Downloading debug-bar (1.1) |
| 38 | + """ |
| 39 | + And STDOUT should contain: |
| 40 | + """ |
| 41 | + Success: Downloaded plugin package to |
| 42 | + """ |
| 43 | + And STDERR should be empty |
| 44 | + |
| 45 | + Scenario: Downloading a non-existent version of a plugin fails with clear error |
| 46 | + Given an empty directory |
| 47 | + |
| 48 | + When I try `wp plugin download debug-bar --version=9.9.9` |
| 49 | + Then STDERR should contain: |
| 50 | + """ |
| 51 | + Error: Can't find the requested plugin's version 9.9.9 |
| 52 | + """ |
| 53 | + And the return code should be 1 |
| 54 | + |
| 55 | + Scenario: Downloading a plugin with --force overwrites existing file |
| 56 | + Given an empty directory |
| 57 | + |
| 58 | + When I run `wp plugin download debug-bar` |
| 59 | + And I run `wp plugin download debug-bar --force` |
| 60 | + Then STDOUT should contain: |
| 61 | + """ |
| 62 | + Success: Downloaded plugin package to |
| 63 | + """ |
| 64 | + And STDERR should be empty |
| 65 | + |
| 66 | + Scenario: Downloading a plugin without --force fails if destination exists |
| 67 | + Given an empty directory |
| 68 | + |
| 69 | + When I run `wp plugin download debug-bar` |
| 70 | + And I try `wp plugin download debug-bar` |
| 71 | + Then STDERR should contain: |
| 72 | + """ |
| 73 | + Error: Destination file already exists: |
| 74 | + """ |
| 75 | + And the return code should be 1 |
| 76 | + |
| 77 | + Scenario: Downloading an unknown plugin fails with a clear error |
| 78 | + Given an empty directory |
| 79 | + |
| 80 | + When I try `wp plugin download this-plugin-does-not-exist-xyz-abc-123` |
| 81 | + Then STDERR should contain: |
| 82 | + """ |
| 83 | + Error: The 'this-plugin-does-not-exist-xyz-abc-123' plugin could not be found. |
| 84 | + """ |
| 85 | + And the return code should be 1 |
| 86 | + |
| 87 | + Scenario: Downloading a theme package works before WordPress is loaded |
| 88 | + Given an empty directory |
| 89 | + |
| 90 | + When I run `wp theme download twentytwelve` |
| 91 | + Then STDOUT should contain: |
| 92 | + """ |
| 93 | + Downloading twentytwelve |
| 94 | + """ |
| 95 | + And STDOUT should contain: |
| 96 | + """ |
| 97 | + Success: Downloaded theme package to |
| 98 | + """ |
| 99 | + And save STDOUT 'Success: Downloaded theme package to (.+)' as {DOWNLOADED_THEME} |
| 100 | + And the {DOWNLOADED_THEME} file should exist |
| 101 | + And STDERR should be empty |
| 102 | + |
| 103 | + Scenario: Downloading a theme package to a custom path |
| 104 | + Given an empty directory |
| 105 | + |
| 106 | + When I run `wp theme download twentytwelve --target-path=/tmp/wp-cli-download-test-theme` |
| 107 | + Then STDOUT should contain: |
| 108 | + """ |
| 109 | + Success: Downloaded theme package to |
| 110 | + """ |
| 111 | + And save STDOUT 'Success: Downloaded theme package to (.+)' as {DOWNLOADED_THEME} |
| 112 | + And the {DOWNLOADED_THEME} file should exist |
| 113 | + And STDERR should be empty |
| 114 | + |
| 115 | + Scenario: Downloading a specific version of a theme |
| 116 | + Given an empty directory |
| 117 | + |
| 118 | + When I run `wp theme download twentytwelve --version=1.3` |
| 119 | + Then STDOUT should contain: |
| 120 | + """ |
| 121 | + Downloading twentytwelve (1.3) |
| 122 | + """ |
| 123 | + And STDOUT should contain: |
| 124 | + """ |
| 125 | + Success: Downloaded theme package to |
| 126 | + """ |
| 127 | + And STDERR should be empty |
| 128 | + |
| 129 | + Scenario: Downloading a non-existent version of a theme fails with clear error |
| 130 | + Given an empty directory |
| 131 | + |
| 132 | + When I try `wp theme download twentytwelve --version=9.9.9` |
| 133 | + Then STDERR should contain: |
| 134 | + """ |
| 135 | + Error: Can't find the requested theme's version 9.9.9 |
| 136 | + """ |
| 137 | + And the return code should be 1 |
| 138 | + |
| 139 | + Scenario: Downloading a theme with --force overwrites existing file |
| 140 | + Given an empty directory |
| 141 | + |
| 142 | + When I run `wp theme download twentytwelve` |
| 143 | + And I run `wp theme download twentytwelve --force` |
| 144 | + Then STDOUT should contain: |
| 145 | + """ |
| 146 | + Success: Downloaded theme package to |
| 147 | + """ |
| 148 | + And STDERR should be empty |
| 149 | + |
| 150 | + Scenario: Downloading a theme without --force fails if destination exists |
| 151 | + Given an empty directory |
| 152 | + |
| 153 | + When I run `wp theme download twentytwelve` |
| 154 | + And I try `wp theme download twentytwelve` |
| 155 | + Then STDERR should contain: |
| 156 | + """ |
| 157 | + Error: Destination file already exists: |
| 158 | + """ |
| 159 | + And the return code should be 1 |
| 160 | + |
| 161 | + Scenario: Downloading an unknown theme fails with a clear error |
| 162 | + Given an empty directory |
| 163 | + |
| 164 | + When I try `wp theme download this-theme-does-not-exist-xyz-abc-123` |
| 165 | + Then STDERR should contain: |
| 166 | + """ |
| 167 | + Error: The 'this-theme-does-not-exist-xyz-abc-123' theme could not be found. |
| 168 | + """ |
| 169 | + And the return code should be 1 |
0 commit comments