Skip to content

Commit c2a04ca

Browse files
authored
Fix tests for SQLite (#168)
* Fix tests for SQLite - Provide `—skip-check` to `wp config create` everywhere - Add a new dedicated test covering `—skip-check` - Rename `wp core config` to `wp config create` in tests so it’s less confusing - Remove some errant whitespace here in some commands * Add more `—skip-check` * Skip test for now * Replace a few more instances
1 parent 9de6ce3 commit c2a04ca

9 files changed

+57
-41
lines changed

features/config-backcompat.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Feature: Backwards compatibility
2222
Given an empty directory
2323
And WP files
2424

25-
When I run `wp core config {CORE_CONFIG_SETTINGS}`
25+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check`
2626
Then STDOUT should contain:
2727
"""
2828
Generated 'wp-config.php' file.

features/config-create.feature

+30-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Feature: Create a wp-config file
22

3+
# Skipped for SQLite because `wp db create` does not yet support SQLite.
4+
# See https://github.com/wp-cli/db-command/issues/234
5+
# and https://github.com/wp-cli/config-command/issues/167
6+
@require-mysql
37
Scenario: No wp-config.php
48
Given an empty directory
59
And WP files
@@ -24,7 +28,7 @@ Feature: Create a wp-config file
2428
define( 'WP_DEBUG_LOG', true );
2529
"""
2630

27-
When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < wp-config-extra.php`
31+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < wp-config-extra.php`
2832
Then the wp-config.php file should contain:
2933
"""
3034
'AUTH_SALT',
@@ -43,7 +47,7 @@ Feature: Create a wp-config file
4347
define( 'WP_DEBUG_LOG', true );
4448
"""
4549
46-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php`
50+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php`
4751
Then the wp-custom-config.php file should contain:
4852
"""
4953
'AUTH_SALT',
@@ -74,7 +78,7 @@ Feature: Create a wp-config file
7478
define( 'WP_DEBUG', true );
7579
"""
7680
77-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php`
81+
When I run `wp config create {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php`
7882
Then the wp-custom-config.php file should contain:
7983
"""
8084
define( 'WP_DEBUG', true );
@@ -99,7 +103,7 @@ Feature: Create a wp-config file
99103
define( 'WP_DEBUG_LOG', true );
100104
"""
101105
102-
When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < wp-config-extra.php`
106+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < wp-config-extra.php`
103107
Then the wp-config.php file should not contain:
104108
"""
105109
define( 'WPLANG', '' );
@@ -109,7 +113,7 @@ Feature: Create a wp-config file
109113
Given an empty directory
110114
And WP files
111115
112-
When I run `wp core config {CORE_CONFIG_SETTINGS} --skip-salts --extra-php < /dev/null`
116+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --skip-salts --extra-php < /dev/null`
113117
Then the wp-config.php file should not contain:
114118
"""
115119
define('AUTH_SALT',
@@ -123,33 +127,45 @@ Feature: Create a wp-config file
123127
Given an empty directory
124128
And WP files
125129
126-
When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=sompassword --dbprefix=""`
130+
When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --dbprefix=""`
127131
Then the return code should be 1
128132
And STDERR should contain:
129133
"""
130134
Error: --dbprefix cannot be empty
131135
"""
132136
133-
When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=sompassword --dbprefix=" "`
137+
When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --dbprefix=" "`
134138
Then the return code should be 1
135139
And STDERR should contain:
136140
"""
137141
Error: --dbprefix can only contain numbers, letters, and underscores.
138142
"""
139143
140-
When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=sompassword --dbprefix="wp-"`
144+
When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --dbprefix="wp-"`
141145
Then the return code should be 1
142146
And STDERR should contain:
143147
"""
144148
Error: --dbprefix can only contain numbers, letters, and underscores.
145149
"""
146150
151+
@require-mysql
152+
Scenario: Configure with invalid database credentials
153+
Given an empty directory
154+
And WP files
155+
156+
When I try `wp config create --dbname=somedb --dbuser=someuser --dbpass=somepassword`
157+
Then the return code should be 1
158+
And STDERR should contain:
159+
"""
160+
Error: Database connection error
161+
"""
162+
147163
@require-php-7.0
148164
Scenario: Configure with salts generated
149165
Given an empty directory
150166
And WP files
151167
152-
When I run `wp core config {CORE_CONFIG_SETTINGS}`
168+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check`
153169
Then the wp-config.php file should contain:
154170
"""
155171
define( 'AUTH_SALT',
@@ -160,7 +176,7 @@ Feature: Create a wp-config file
160176
Given an empty directory
161177
And WP files
162178
163-
When I run `wp core config {CORE_CONFIG_SETTINGS}`
179+
When I run `wp config create {CORE_CONFIG_SETTINGS}`
164180
Then the wp-config.php file should contain:
165181
"""
166182
define( 'AUTH_SALT',
@@ -170,20 +186,20 @@ Feature: Create a wp-config file
170186
Given an empty directory
171187
And I run `wp core download --version=3.9 --force`
172188
173-
When I run `wp core config {CORE_CONFIG_SETTINGS}`
189+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check`
174190
Then the wp-config.php file should contain:
175191
"""
176192
define( 'WPLANG', '' );
177193
"""
178194
179-
When I try `wp core config {CORE_CONFIG_SETTINGS}`
195+
When I try `wp config create {CORE_CONFIG_SETTINGS}`
180196
Then the return code should be 1
181197
And STDERR should contain:
182198
"""
183199
Error: The 'wp-config.php' file already exists.
184200
"""
185201
186-
When I run `wp core config {CORE_CONFIG_SETTINGS} --locale=ja --force`
202+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --locale=ja --force`
187203
Then the return code should be 0
188204
And STDOUT should contain:
189205
"""
@@ -194,7 +210,7 @@ Feature: Create a wp-config file
194210
define( 'WPLANG', 'ja' );
195211
"""
196212
197-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file=wp-custom-config.php --locale=ja --force`
213+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file=wp-custom-config.php --locale=ja --force`
198214
Then the return code should be 0
199215
And STDOUT should contain:
200216
"""

features/config-delete.feature

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Feature: Delete a constant or variable from the wp-config.php file
4747
Given an empty directory
4848
And WP files
4949

50-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
50+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
5151
Then STDOUT should contain:
5252
"""
5353
Generated 'wp-custom-config.php' file.
@@ -117,7 +117,7 @@ Feature: Delete a constant or variable from the wp-config.php file
117117
Given an empty directory
118118
And WP files
119119

120-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
120+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
121121
Then STDOUT should contain:
122122
"""
123123
Generated 'wp-custom-config.php' file.
@@ -173,7 +173,7 @@ Feature: Delete a constant or variable from the wp-config.php file
173173
Given an empty directory
174174
And WP files
175175

176-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
176+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
177177
Then STDOUT should contain:
178178
"""
179179
Generated 'wp-custom-config.php' file.

features/config-edit.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Feature: Edit a wp-config file
1515
Given an empty directory
1616
And WP files
1717

18-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
18+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
1919
Then STDOUT should contain:
2020
"""
2121
Generated 'wp-custom-config.php' file.

features/config-get-field.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Feature: Get the value of a constant or variable defined in wp-config.php and wp
164164
Given an empty directory
165165
And WP files
166166

167-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
167+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
168168
Then STDOUT should contain:
169169
"""
170170
Generated 'wp-custom-config.php' file.
@@ -269,7 +269,7 @@ Feature: Get the value of a constant or variable defined in wp-config.php and wp
269269
Given an empty directory
270270
And WP files
271271

272-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
272+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
273273
Then STDOUT should contain:
274274
"""
275275
Generated 'wp-custom-config.php' file.

features/config-has.feature

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feature: Check whether the wp-config.php file or the wp-custom-config.php file h
2020
Given an empty directory
2121
And WP files
2222

23-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
23+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
2424
Then STDOUT should contain:
2525
"""
2626
Generated 'wp-custom-config.php' file.
@@ -29,11 +29,11 @@ Feature: Check whether the wp-config.php file or the wp-custom-config.php file h
2929
Then STDOUT should be empty
3030
And the return code should be 0
3131

32-
When I run `wp config has DB_USER --type=constant --config-file='wp-custom-config.php'`
32+
When I run `wp config has DB_USER --type=constant --config-file='wp-custom-config.php'`
3333
Then STDOUT should be empty
3434
And the return code should be 0
3535

36-
When I run `wp config has table_prefix --type=variable --config-file='wp-custom-config.php'`
36+
When I run `wp config has table_prefix --type=variable --config-file='wp-custom-config.php'`
3737
Then STDOUT should be empty
3838
And the return code should be 0
3939

@@ -70,7 +70,7 @@ Feature: Check whether the wp-config.php file or the wp-custom-config.php file h
7070
Given an empty directory
7171
And WP files
7272

73-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
73+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
7474
Then STDOUT should contain:
7575
"""
7676
Generated 'wp-custom-config.php' file.
@@ -133,7 +133,7 @@ Feature: Check whether the wp-config.php file or the wp-custom-config.php file h
133133
Given an empty directory
134134
And WP files
135135

136-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
136+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
137137
Then STDOUT should contain:
138138
"""
139139
Generated 'wp-custom-config.php' file.

features/config-list.feature

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Feature: List the values of a wp-config.php file
1212
<?php // This won't work without this file being empty. ?>
1313
"""
1414

15-
When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < wp-config-extra.php`
15+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < wp-config-extra.php`
1616
Then STDOUT should contain:
1717
"""
1818
Generated 'wp-config.php' file.
@@ -43,7 +43,7 @@ Feature: List the values of a wp-config.php file
4343
<?php // This won't work without this file being empty. ?>
4444
"""
4545
46-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php`
46+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php`
4747
Then STDOUT should contain:
4848
"""
4949
Generated 'wp-custom-config.php' file.
@@ -66,7 +66,7 @@ Feature: List the values of a wp-config.php file
6666
Given an empty directory
6767
And WP files
6868
69-
When I run `wp core config {CORE_CONFIG_SETTINGS}`
69+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check`
7070
Then STDOUT should contain:
7171
"""
7272
Generated 'wp-config.php' file.
@@ -198,13 +198,13 @@ Feature: List the values of a wp-config.php file
198198
Given an empty directory
199199
And WP files
200200
201-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
201+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
202202
Then STDOUT should contain:
203203
"""
204204
Generated 'wp-custom-config.php' file.
205205
"""
206206
207-
When I run `wp config list --fields=name --config-file='wp-custom-config.php'`
207+
When I run `wp config list --fields=name --config-file='wp-custom-config.php'`
208208
Then STDOUT should be a table containing rows:
209209
| name |
210210
| table_prefix |

features/config-set.feature

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a
2020
Given an empty directory
2121
And WP files
2222

23-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
23+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
2424
Then STDOUT should contain:
2525
"""
2626
Generated 'wp-custom-config.php' file.
@@ -80,7 +80,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a
8080
Given an empty directory
8181
And WP files
8282

83-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
83+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
8484
Then STDOUT should contain:
8585
"""
8686
Generated 'wp-custom-config.php' file.
@@ -168,11 +168,11 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a
168168
"""
169169

170170
@custom-config-file
171-
Scenario: Updating a non-existent value in wp-custom-config.php without --add
171+
Scenario: Updating a non-existent value in wp-custom-config.php without --add
172172
Given an empty directory
173173
And WP files
174174

175-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
175+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
176176
Then STDOUT should contain:
177177
"""
178178
Generated 'wp-custom-config.php' file.
@@ -252,7 +252,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a
252252
Given an empty directory
253253
And WP files
254254

255-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
255+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
256256
Then STDOUT should contain:
257257
"""
258258
Generated 'wp-custom-config.php' file.
@@ -314,19 +314,19 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a
314314
Given an empty directory
315315
And WP files
316316

317-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
317+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
318318
Then STDOUT should contain:
319319
"""
320320
Generated 'wp-custom-config.php' file.
321321
"""
322322

323-
When I run `wp config set SOME_NAME some_value --type=constant --config-file='wp-custom-config.php'`
323+
When I run `wp config set SOME_NAME some_value --type=constant --config-file='wp-custom-config.php'`
324324
Then STDOUT should be:
325325
"""
326326
Success: Added the constant 'SOME_NAME' to the 'wp-custom-config.php' file with the value 'some_value'.
327327
"""
328328

329-
When I run `wp config set SOME_NAME some_value --type=variable --config-file='wp-custom-config.php'`
329+
When I run `wp config set SOME_NAME some_value --type=variable --config-file='wp-custom-config.php'`
330330
Then STDOUT should be:
331331
"""
332332
Success: Added the variable 'SOME_NAME' to the 'wp-custom-config.php' file with the value 'some_value'.

features/config-shuffle-salts.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Feature: Refresh the salts in the wp-config.php file
2424
Given an empty directory
2525
And WP files
2626

27-
When I run `wp core config {CORE_CONFIG_SETTINGS} --skip-salts=true --config-file='wp-custom-config.php'`
27+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --skip-salts=true --config-file='wp-custom-config.php'`
2828
Then STDOUT should contain:
2929
"""
3030
Generated 'wp-custom-config.php' file.
@@ -131,7 +131,7 @@ Feature: Refresh the salts in the wp-config.php file
131131
Given an empty directory
132132
And WP files
133133

134-
When I run `wp core config {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php'`
134+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
135135
Then STDOUT should contain:
136136
"""
137137
Generated 'wp-custom-config.php' file.

0 commit comments

Comments
 (0)