Skip to content

Commit 827f541

Browse files
authored
Merge pull request #114 from wp-cli/add/root-db-vars
2 parents 7a6a9de + df036da commit 827f541

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/Context/FeatureContext.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,24 +482,34 @@ public static function create_cache_dir() {
482482
* Every scenario gets its own context object.
483483
*/
484484
public function __construct() {
485+
if ( getenv( 'WP_CLI_TEST_DBROOTUSER' ) ) {
486+
$this->variables['DB_ROOT_USER'] = getenv( 'WP_CLI_TEST_DBROOTUSER' );
487+
}
488+
489+
if ( false !== getenv( 'WP_CLI_TEST_DBROOTPASS' ) ) {
490+
$this->variables['DB_ROOT_PASSWORD'] = getenv( 'WP_CLI_TEST_DBROOTPASS' );
491+
}
492+
485493
if ( getenv( 'WP_CLI_TEST_DBUSER' ) ) {
486-
self::$db_settings['dbuser'] = getenv( 'WP_CLI_TEST_DBUSER' );
494+
$this->variables['DB_USER'] = getenv( 'WP_CLI_TEST_DBUSER' );
487495
}
488496

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

493501
if ( getenv( 'WP_CLI_TEST_DBHOST' ) ) {
494-
self::$db_settings['dbhost'] = getenv( 'WP_CLI_TEST_DBHOST' );
502+
$this->variables['DB_HOST'] = getenv( 'WP_CLI_TEST_DBHOST' );
495503
}
496504

505+
self::$db_settings['dbuser'] = $this->variables['DB_USER'];
506+
self::$db_settings['dbpass'] = $this->variables['DB_PASSWORD'];
507+
self::$db_settings['dbhost'] = $this->variables['DB_HOST'];
508+
509+
$this->variables['CORE_CONFIG_SETTINGS'] = Utils\assoc_args_to_str( self::$db_settings );
510+
497511
$this->drop_db();
498512
$this->set_cache_dir();
499-
$this->variables['DB_USER'] = self::$db_settings['dbuser'];
500-
$this->variables['DB_PASSWORD'] = self::$db_settings['dbpass'];
501-
$this->variables['DB_HOST'] = self::$db_settings['dbhost'];
502-
$this->variables['CORE_CONFIG_SETTINGS'] = Utils\assoc_args_to_str( self::$db_settings );
503513
}
504514

505515
/**

0 commit comments

Comments
 (0)