-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathscaffold-package.feature
More file actions
322 lines (284 loc) · 10.2 KB
/
scaffold-package.feature
File metadata and controls
322 lines (284 loc) · 10.2 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
Feature: Scaffold WP-CLI commands
Scenario: Scaffold a WP-CLI command without tests
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/foo --skip-tests`
Then STDOUT should contain:
"""
Success: Created package files
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/.gitignore file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.editorconfig file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.distignore file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.distignore file should contain:
"""
.gitignore
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should contain:
"""
WP_CLI_CS
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should contain:
"""
wpcli_foo
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
"""
"type": "wp-cli-package",
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
"""
"homepage": "https://github.com/wp-cli/foo",
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
"""
"license": "MIT",
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
"""
"require": {
"wp-cli/wp-cli": "^2.13"
},
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/hello-world-command.php file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/CONTRIBUTING.md file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/CONTRIBUTING.md file should contain:
"""
Contributing
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should contain:
"""
The MIT License (MIT)
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/LICENSE file should contain:
"""
wp-cli/foo Contributors
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/wp-cli.yml file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.travis.yml file should not exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/ISSUE_TEMPLATE file should exist
When I run `wp hello-world`
Then STDOUT should be:
"""
Success: Hello World!
"""
When I run `composer -q -n --working-dir={PACKAGE_PATH}/local/wp-cli/foo/ install`
And I run `wp --require={PACKAGE_PATH}/local/wp-cli/foo/hello-world-command.php hello-world`
Then STDOUT should be:
"""
Success: Hello World!
"""
When I run `cat {PACKAGE_PATH}/local/wp-cli/foo/wp-cli.yml`
Then STDOUT should contain:
"""
require:
- hello-world-command.php
"""
When I run `cat {PACKAGE_PATH}/local/wp-cli/foo/.gitignore`
Then STDOUT should contain:
"""
.DS_Store
"""
When I run `cat {PACKAGE_PATH}/local/wp-cli/foo/.editorconfig`
Then STDOUT should contain:
"""
This file is for unifying the coding style for different editors and IDEs
"""
When I run `wp package uninstall wp-cli/foo`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a WP-CLI command without using --require
Given an empty directory
When I run `wp scaffold package wp-cli/without-require --skip-tests`
Then STDOUT should contain:
"""
Success: Created package files
"""
When I run `wp hello-world`
Then STDOUT should be:
"""
Success: Hello World!
"""
When I run `wp package uninstall wp-cli/without-require`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a package with an invalid name
Given an empty directory
When I try `wp scaffold package foo`
Then STDERR should be:
"""
Error: 'foo' is an invalid package name. Package scaffold expects '<author>/<package>'.
"""
And the return code should be 1
Scenario: Scaffold a WP-CLI command to a custom directory
Given an empty directory
When I run `wp scaffold package wp-cli/custom-directory --dir=custom-directory --skip-tests`
Then STDOUT should contain:
"""
Success: Created package files
"""
And the custom-directory/.gitignore file should exist
And the custom-directory/.editorconfig file should exist
And the custom-directory/phpcs.xml.dist file should exist
And the custom-directory/composer.json file should exist
And the custom-directory/LICENSE file should exist
And the custom-directory/hello-world-command.php file should exist
And the custom-directory/wp-cli.yml file should exist
And the custom-directory/.travis.yml file should not exist
When I run `composer -q -n --working-dir=custom-directory/ install`
And I run `wp --require=custom-directory/hello-world-command.php hello-world`
Then STDOUT should be:
"""
Success: Hello World!
"""
When I run `wp package uninstall wp-cli/custom-directory`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Attempt to scaffold the same package twice
Given an empty directory
And a session file:
"""
s
s
s
s
s
s
s
s
s
s
s
"""
When I try `wp scaffold package wp-cli/same-package --skip-tests --skip-github`
Then STDOUT should contain:
"""
Success: Created package files
"""
When I try `wp scaffold package wp-cli/same-package --skip-tests --skip-github < session`
And STDERR should contain:
"""
Warning: File already exists
"""
Then STDOUT should contain:
"""
All package files were skipped
"""
And the return code should be 0
When I try `wp package uninstall wp-cli/same-package`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a WP-CLI command with tests
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/with-tests`
Then STDOUT should contain:
"""
Success: Created package files
"""
And the {PACKAGE_PATH}/local/wp-cli/with-tests/.gitignore file should exist
And the {PACKAGE_PATH}/local/wp-cli/with-tests/.editorconfig file should exist
And the {PACKAGE_PATH}/local/wp-cli/with-tests/phpcs.xml.dist file should exist
And the {PACKAGE_PATH}/local/wp-cli/with-tests/composer.json file should exist
And the {PACKAGE_PATH}/local/wp-cli/with-tests/hello-world-command.php file should exist
And the {PACKAGE_PATH}/local/wp-cli/with-tests/wp-cli.yml file should exist
And the {PACKAGE_PATH}/local/wp-cli/with-tests/.travis.yml file should exist
When I run `composer -q -n --working-dir={PACKAGE_PATH}/local/wp-cli/with-tests/ install`
And I run `wp --require={PACKAGE_PATH}/local/wp-cli/with-tests/hello-world-command.php hello-world`
Then STDOUT should be:
"""
Success: Hello World!
"""
When I run `wp package uninstall wp-cli/with-tests`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Scaffold a command with a custom homepage
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/bar --homepage='http://apple.com'`
Then STDOUT should contain:
"""
Success: Created package files
"""
And the {PACKAGE_PATH}/local/wp-cli/bar/composer.json file should exist
And the {PACKAGE_PATH}/local/wp-cli/bar/composer.json file should contain:
"""
"homepage": "http://apple.com",
"""
When I run `wp package uninstall wp-cli/bar`
Then STDOUT should contain:
"""
Success: Uninstalled package.
"""
Scenario: Use tilde for HOME in package directory path
Given an empty directory
When I run `HOME={RUN_DIR} wp scaffold package bar/foo --dir=~/foo --force --skip-tests --skip-readme`
Then STDOUT should contain:
"""
Success: Package installed.
"""
And the {RUN_DIR}/foo directory should exist
Scenario: Scaffold a package but skip installation and GitHub templates
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/foo --skip-install --skip-github`
Then STDOUT should contain:
"""
Success: Created package files
"""
And STDOUT should not contain:
"""
Installing package
"""
And the {PACKAGE_PATH}/local/wp-cli/foo/.gitignore file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/phpcs.xml.dist file should exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/PULL_REQUEST_TEMPLATE file should not exist
And the {PACKAGE_PATH}/local/wp-cli/foo/.github/ISSUE_TEMPLATE file should not exist
Scenario: Scaffolded package includes autoloader documentation
Given an empty directory
When I run `wp package path`
Then save STDOUT as {PACKAGE_PATH}
When I run `wp scaffold package wp-cli/foo --skip-tests --skip-readme --skip-github --skip-install`
Then STDOUT should contain:
"""
Success: Created package files
"""
And STDOUT should contain:
"""
Next steps:
"""
And STDOUT should contain:
"""
composer dump-autoload
"""
When I run `cat {PACKAGE_PATH}/local/wp-cli/foo/src/HelloWorldCommand.php`
Then STDOUT should contain:
"""
IMPORTANT: After modifying this file or adding new command classes, you need to
"""
And STDOUT should contain:
"""
composer dump-autoload --working-dir=$(wp package path)
"""
And STDOUT should contain:
"""
https://getcomposer.org/doc/01-basic-usage.md#autoloading
"""