Feature: Create a wp-config file # Skipped for SQLite because `wp db create` does not yet support SQLite. # See https://github.com/wp-cli/db-command/issues/234 # and https://github.com/wp-cli/config-command/issues/167 @require-mysql Scenario: No wp-config.php Given an empty directory And WP files When I try `wp core is-installed` Then the return code should be 1 And STDERR should not be empty When I run `wp core version` Then STDOUT should not be empty When I try `wp core install` Then the return code should be 1 And STDERR should be: """ Error: 'wp-config.php' not found. Either create one manually or use `wp config create`. """ Given a wp-config-extra.php file: """ define( 'WP_DEBUG_LOG', true ); """ When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < wp-config-extra.php` Then the wp-config.php file should contain: """ 'AUTH_SALT', """ And the wp-config.php file should contain: """ define( 'WP_DEBUG_LOG', true ); """ When I try the previous command again Then the return code should be 1 And STDERR should not be empty Given a wp-config-extra.php file: """ define( 'WP_DEBUG_LOG', true ); """ When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php` Then the wp-custom-config.php file should contain: """ 'AUTH_SALT', """ And the wp-custom-config.php file should contain: """ define( 'WP_DEBUG_LOG', true ); """ When I try the previous command again Then the return code should be 1 And STDERR should not be empty When I run `wp db create` Then STDOUT should not be empty When I try `wp option get option home` Then STDERR should contain: """ Error: The site you have requested is not installed """ When I run `rm wp-custom-config.php` Then the wp-custom-config.php file should not exist Given a wp-config-extra.php file: """ define( 'WP_DEBUG', true ); """ When I run `wp config create {CORE_CONFIG_SETTINGS} --config-file='wp-custom-config.php' --extra-php < wp-config-extra.php` Then the wp-custom-config.php file should contain: """ define( 'WP_DEBUG', true ); """ And the wp-custom-config.php file should contain: """ define( 'WP_DEBUG', false ); """ When I try `wp version` Then STDERR should not contain: """ Constant WP_DEBUG already defined """ @require-wp-4.0 Scenario: No wp-config.php and WPLANG Given an empty directory And WP files And a wp-config-extra.php file: """ define( 'WP_DEBUG_LOG', true ); """ When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < wp-config-extra.php` Then the wp-config.php file should not contain: """ define( 'WPLANG', '' ); """ Scenario: Configure with existing salts Given an empty directory And WP files When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --skip-salts --extra-php < /dev/null` Then the wp-config.php file should not contain: """ define('AUTH_SALT', """ And the wp-config.php file should not contain: """ define( 'AUTH_SALT', """ Scenario: Configure with invalid table prefix Given an empty directory And WP files When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --dbprefix=""` Then the return code should be 1 And STDERR should contain: """ Error: --dbprefix cannot be empty """ When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --dbprefix=" "` Then the return code should be 1 And STDERR should contain: """ Error: --dbprefix can only contain numbers, letters, and underscores. """ When I try `wp config create --skip-check --dbname=somedb --dbuser=someuser --dbpass=somepassword --dbprefix="wp-"` Then the return code should be 1 And STDERR should contain: """ Error: --dbprefix can only contain numbers, letters, and underscores. """ @require-mysql Scenario: Configure with invalid database credentials Given an empty directory And WP files When I try `wp config create --dbname=somedb --dbuser=someuser --dbpass=somepassword` Then the return code should be 1 And STDERR should contain: """ Error: Database connection error """ @require-mysql Scenario: Configure with database credentials using socket path Given an empty directory And WP files And a find-socket.php file: """