Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions features/config-create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,48 @@ Feature: Create a wp-config file
Error: Database connection error
"""

Scenario: Missing --dbname with --skip-check
Given an empty directory
And WP files

When I run `wp config create --skip-check --dbuser=someuser`
Then the wp-config.php file should contain:
"""
define( 'DB_NAME', '' );
"""
And the wp-config.php file should contain:
"""
define( 'DB_USER', 'someuser' );
"""

Scenario: Missing --dbuser with --skip-check
Given an empty directory
And WP files

When I run `wp config create --skip-check --dbname=somedb`
Then the wp-config.php file should contain:
"""
define( 'DB_NAME', 'somedb' );
"""
And the wp-config.php file should contain:
"""
define( 'DB_USER', '' );
"""

@require-mysql
Scenario: Missing --dbname or --dbuser without SQLite integration
Scenario: Missing --dbname or --dbuser without --skip-check
Given an empty directory
And WP files

When I try `wp config create --skip-check --dbuser=someuser`
When I try `wp config create --dbuser=someuser`
Then the return code should be 1
And STDERR should contain:
"""
Error: Parameter errors:
missing --dbname parameter (Set the database name.)
"""

When I try `wp config create --skip-check --dbname=somedb`
When I try `wp config create --dbname=somedb`
Then the return code should be 1
And STDERR should contain:
"""
Expand Down
8 changes: 5 additions & 3 deletions src/Config_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ private static function get_initial_locale() {
* ## OPTIONS
*
* [--dbname=<dbname>]
* : Set the database name. Required unless the SQLite integration drop-in is detected.
* : Set the database name. Required unless `--skip-check` is used or the SQLite integration drop-in is detected.
*
* [--dbuser=<dbuser>]
* : Set the database user. Required unless the SQLite integration drop-in is detected.
* : Set the database user. Required unless `--skip-check` is used or the SQLite integration drop-in is detected.
*
* [--dbpass=<dbpass>]
* : Set the database user password.
Expand Down Expand Up @@ -209,6 +209,8 @@ public function create( $_, $assoc_args ) {
}

$defaults = [
'dbname' => '',
'dbuser' => '',
'dbhost' => 'localhost',
'dbpass' => '',
'dbprefix' => 'wp_',
Expand All @@ -222,7 +224,7 @@ public function create( $_, $assoc_args ) {

$is_sqlite = self::is_sqlite_integration_active();

if ( ! $is_sqlite ) {
if ( ! $is_sqlite && ! Utils\get_flag_value( $assoc_args, 'skip-check' ) ) {
$errors = [];
if ( empty( $assoc_args['dbname'] ) ) {
$errors[] = 'missing --dbname parameter (Set the database name.)';
Expand Down