Skip to content

Commit

Permalink
Handle missing DB credentials gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed May 5, 2021
1 parent 6b6f201 commit 7ec79e7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,17 @@ public function __construct() {
$this->variables['MYSQL_HOST'] = getenv( 'MYSQL_HOST' );
}

self::$db_settings['dbuser'] = $this->variables['DB_USER'];
self::$db_settings['dbpass'] = $this->variables['DB_PASSWORD'];
self::$db_settings['dbhost'] = $this->variables['DB_HOST'];
self::$db_settings['dbuser'] = array_key_exists( 'DB_USER', $this->variables )
? $this->variables['DB_USER']
: 'wp_cli_test';

self::$db_settings['dbpass'] = array_key_exists( 'DB_PASSWORD', $this->variables )
? $this->variables['DB_PASSWORD']
: 'password1';

self::$db_settings['dbhost'] = array_key_exists( 'DB_HOST', $this->variables )
? $this->variables['DB_HOST']
: 'localhost';

$this->variables['CORE_CONFIG_SETTINGS'] = Utils\assoc_args_to_str( self::$db_settings );

Expand Down

0 comments on commit 7ec79e7

Please sign in to comment.