11Feature : 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 """
0 commit comments