File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,16 +41,16 @@ Feature: Set the value of a constant or variable defined in wp-config.php file
4141 variable_value
4242 """
4343
44- When I try `wp config set SOME_NAME some_value`
45- Then STDERR should be:
44+ When I run `wp config set DEFAULT_TO_CONSTANT some_value`
45+ Then STDOUT should be:
4646 """
47- Error: The constant or variable 'SOME_NAME' is not defined in the 'wp-config.php' file. Specify an explicit --type=<type> to add .
47+ Success: Added the constant 'DEFAULT_TO_CONSTANT' to the 'wp-config.php' file with the value 'some_value' .
4848 """
4949
50- When I try `wp config get SOME_NAME `
51- Then STDERR should be:
50+ When I run `wp config get DEFAULT_TO_CONSTANT `
51+ Then STDOUT should be:
5252 """
53- Error: The constant or variable 'SOME_NAME' is not defined in the 'wp-config.php' file.
53+ some_value
5454 """
5555
5656 Scenario : Updating a non-existent value without --add
Original file line number Diff line number Diff line change @@ -474,11 +474,12 @@ public function set( $args, $assoc_args ) {
474474 WP_CLI ::error ( "Found both a constant and a variable ' {$ name }' in the 'wp-config.php' file. Use --type=<type> to disambiguate. " );
475475 }
476476 if ( ! $ has_constant && ! $ has_variable ) {
477- $ message = " The constant or variable ' { $ name } ' is not defined in the 'wp-config.php' file. " ;
478- if ( $ options [ ' add ' ] ) {
479- $ message .= ' Specify an explicit --type=<type> to add. ' ;
477+ if ( ! $ options [ ' add ' ] ) {
478+ $ message = " The constant or variable ' { $ name } ' is not defined in the 'wp-config.php' file. " ;
479+ WP_CLI :: error ( $ message ) ;
480480 }
481- WP_CLI ::error ( $ message );
481+ $ type = 'constant ' ;
482+ $ adding = true ;
482483 } else {
483484 $ type = $ has_constant ? 'constant ' : 'variable ' ;
484485 }
You can’t perform that action at this time.
0 commit comments