Skip to content

Commit

Permalink
Merge pull request #114 from wp-cli/add/root-db-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Mar 6, 2021
2 parents 7a6a9de + df036da commit 827f541
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,24 +482,34 @@ public static function create_cache_dir() {
* Every scenario gets its own context object.
*/
public function __construct() {
if ( getenv( 'WP_CLI_TEST_DBROOTUSER' ) ) {
$this->variables['DB_ROOT_USER'] = getenv( 'WP_CLI_TEST_DBROOTUSER' );
}

if ( false !== getenv( 'WP_CLI_TEST_DBROOTPASS' ) ) {
$this->variables['DB_ROOT_PASSWORD'] = getenv( 'WP_CLI_TEST_DBROOTPASS' );
}

if ( getenv( 'WP_CLI_TEST_DBUSER' ) ) {
self::$db_settings['dbuser'] = getenv( 'WP_CLI_TEST_DBUSER' );
$this->variables['DB_USER'] = getenv( 'WP_CLI_TEST_DBUSER' );
}

if ( false !== getenv( 'WP_CLI_TEST_DBPASS' ) ) {
self::$db_settings['dbpass'] = getenv( 'WP_CLI_TEST_DBPASS' );
$this->variables['DB_PASSWORD'] = getenv( 'WP_CLI_TEST_DBPASS' );
}

if ( getenv( 'WP_CLI_TEST_DBHOST' ) ) {
self::$db_settings['dbhost'] = getenv( 'WP_CLI_TEST_DBHOST' );
$this->variables['DB_HOST'] = getenv( 'WP_CLI_TEST_DBHOST' );
}

self::$db_settings['dbuser'] = $this->variables['DB_USER'];
self::$db_settings['dbpass'] = $this->variables['DB_PASSWORD'];
self::$db_settings['dbhost'] = $this->variables['DB_HOST'];

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

$this->drop_db();
$this->set_cache_dir();
$this->variables['DB_USER'] = self::$db_settings['dbuser'];
$this->variables['DB_PASSWORD'] = self::$db_settings['dbpass'];
$this->variables['DB_HOST'] = self::$db_settings['dbhost'];
$this->variables['CORE_CONFIG_SETTINGS'] = Utils\assoc_args_to_str( self::$db_settings );
}

/**
Expand Down

0 comments on commit 827f541

Please sign in to comment.