-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpackage.feature
More file actions
233 lines (206 loc) · 6.21 KB
/
Copy pathpackage.feature
File metadata and controls
233 lines (206 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
Feature: Manage WP-CLI packages
Scenario: Package CRUD
Given an empty directory
When I run `wp package browse`
Then STDOUT should contain:
"""
runcommand/hook
"""
When I run `wp package install runcommand/hook`
Then STDERR should be empty
When I run `wp help hook`
Then STDERR should be empty
And STDOUT should contain:
"""
List callbacks registered to a given action or filter.
"""
When I try `wp --skip-packages --debug help hook`
Then STDERR should contain:
"""
Debug (bootstrap): Skipped loading packages.
"""
And STDERR should contain:
"""
Warning: No WordPress install
"""
When I run `wp package list`
Then STDOUT should contain:
"""
runcommand/hook
"""
When I run `wp package uninstall runcommand/hook`
Then STDERR should be empty
When I run `wp package list`
Then STDOUT should not contain:
"""
runcommand/hook
"""
Scenario: Run package commands early, before any bad code can break them
Given an empty directory
And a bad-command.php file:
"""
<?php
WP_CLI::error( "Doing it wrong." );
"""
When I try `wp --require=bad-command.php option`
Then STDERR should contain:
"""
Error: Doing it wrong.
"""
When I run `wp --require=bad-command.php package list`
Then STDERR should be empty
@require-php-7.2 @broken
Scenario: Revert the WP-CLI packages composer.json when fail to install/uninstall a package due to memory limit
Given an empty directory
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--dmemory_limit=10M -ddisable_functions=ini_set} package install runcommand/hook`
Then the return code should not be 0
And STDERR should contain:
"""
Reverted composer.json.
"""
When I run `wp package install runcommand/hook`
Then STDOUT should contain:
"""
Success: Package installed.
"""
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--dmemory_limit=10M -ddisable_functions=ini_set} package uninstall runcommand/hook`
Then the return code should not be 0
And STDERR should contain:
"""
Reverted composer.json.
"""
# Create a default composer.json first to compare.
When I run `WP_CLI_PACKAGES_DIR={RUN_DIR}/mypackages wp package list`
Then the {RUN_DIR}/mypackages/composer.json file should exist
And save the {RUN_DIR}/mypackages/composer.json file as {MYPACKAGES_COMPOSER_JSON}
When I try `WP_CLI_PACKAGES_DIR={RUN_DIR}/mypackages {INVOKE_WP_CLI_WITH_PHP_ARGS--dmemory_limit=10M -ddisable_functions=ini_set} package install runcommand/hook`
Then the return code should not be 0
And STDERR should contain:
"""
Reverted composer.json.
"""
And the mypackages/composer.json file should be:
"""
{MYPACKAGES_COMPOSER_JSON}
"""
@github-api
Scenario: Try to run with a bad WP_CLI_PACKAGES_DIR/composer.json
Given an empty directory
And a packages-bad-json/composer.json file:
"""
{
"name": "wp-cli/wp-cli",
}
"""
When I try `WP_CLI_PACKAGES_DIR={RUN_DIR}/packages-bad-json wp package list`
Then the return code should be 1
And STDERR should contain:
"""
Error: Failed to get composer instance
"""
And STDERR should contain:
"""
Parse error
"""
And STDOUT should be empty
When I try `WP_CLI_PACKAGES_DIR={RUN_DIR}/packages-bad-json wp package install runcommand/hook`
Then the return code should be 1
And STDERR should contain:
"""
Error: Failed to parse
"""
And STDERR should contain:
"""
Parse error
"""
And STDOUT should contain:
"""
Installing
"""
When I try `WP_CLI_PACKAGES_DIR={RUN_DIR}/packages-bad-json wp package update`
Then the return code should be 1
And STDERR should contain:
"""
Error: Failed to get composer instance
"""
And STDERR should contain:
"""
Parse error
"""
And STDOUT should be empty
Given a packages-no-such-package/composer.json file:
"""
{
"name": "wp-cli/wp-cli",
"repositories": {
"no-such-gituser/no-such-package": {
"type": "vcs",
"url": "https://github.com/no-such-gituser/no-such-package.git"
}
},
"require": {
"no-such-gituser/no-such-package": "dev-master"
}
}
"""
And save the {RUN_DIR}/packages-no-such-package/composer.json file as {NO_SUCH_PACKAGE_COMPOSER_JSON}
When I try `WP_CLI_PACKAGES_DIR={RUN_DIR}/packages-no-such-package wp package install runcommand/hook`
Then the return code should be 1
And STDERR should contain:
"""
Error: Package installation failed.
"""
And STDERR should contain:
"""
Repository not found
"""
And STDERR should contain:
"""
Reverted composer.json.
"""
And STDOUT should contain:
"""
Installing
"""
And the packages-no-such-package/composer.json file should be:
"""
{NO_SUCH_PACKAGE_COMPOSER_JSON}
"""
When I try `WP_CLI_PACKAGES_DIR={RUN_DIR}/packages-no-such-package wp package update`
Then the return code should be 1
And STDERR should contain:
"""
Error: Failed to update packages.
"""
And STDERR should contain:
"""
Repository not found
"""
And STDERR should not contain:
"""
Reverted composer.json.
"""
And STDOUT should not be empty
And the packages-no-such-package/composer.json file should be:
"""
{NO_SUCH_PACKAGE_COMPOSER_JSON}
"""
Scenario: List packages with --skip-update-check flag
Given an empty directory
When I run `wp package install runcommand/hook`
Then STDERR should be empty
When I run `wp package list --skip-update-check --fields=name,update,update_version`
Then STDOUT should contain:
"""
runcommand/hook
"""
And STDOUT should contain:
"""
none
"""
And STDOUT should not contain:
"""
available
"""
When I run `wp package uninstall runcommand/hook`
Then STDERR should be empty