-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathconfig-add.feature
More file actions
138 lines (116 loc) · 4.36 KB
/
config-add.feature
File metadata and controls
138 lines (116 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Feature: Add a constant or variable to wp-config.php file
Scenario: Add a new constant to wp-config.php
Given a WP install
When I run `wp config add NEW_CONSTANT constant_value`
Then STDOUT should be:
"""
Success: Added the constant 'NEW_CONSTANT' to the 'wp-config.php' file with the value 'constant_value'.
"""
When I run `wp config get NEW_CONSTANT`
Then STDOUT should be:
"""
constant_value
"""
Scenario: Add a new variable to wp-config.php
Given a WP install
When I run `wp config add new_variable variable_value --type=variable`
Then STDOUT should be:
"""
Success: Added the variable 'new_variable' to the 'wp-config.php' file with the value 'variable_value'.
"""
When I run `wp config get new_variable`
Then STDOUT should be:
"""
variable_value
"""
Scenario: Add a raw constant to wp-config.php
Given a WP install
When I run `wp config add WP_CUSTOM_CONSTANT true --raw`
Then STDOUT should be:
"""
Success: Added the constant 'WP_CUSTOM_CONSTANT' to the 'wp-config.php' file with the raw value 'true'.
"""
When I run `wp config list WP_CUSTOM_CONSTANT --strict --format=json`
Then STDOUT should contain:
"""
{"name":"WP_CUSTOM_CONSTANT","value":true,"type":"constant"}
"""
Scenario: Fail when trying to add an existing constant
Given a WP install
When I run `wp config add TEST_CONSTANT test_value`
Then STDOUT should be:
"""
Success: Added the constant 'TEST_CONSTANT' to the 'wp-config.php' file with the value 'test_value'.
"""
When I try `wp config add TEST_CONSTANT another_value`
Then STDERR should be:
"""
Error: The constant 'TEST_CONSTANT' already exists in the 'wp-config.php' file.
"""
Scenario: Fail when trying to add an existing variable
Given a WP install
When I run `wp config add test_variable test_value --type=variable`
Then STDOUT should be:
"""
Success: Added the variable 'test_variable' to the 'wp-config.php' file with the value 'test_value'.
"""
When I try `wp config add test_variable another_value --type=variable`
Then STDERR should be:
"""
Error: The variable 'test_variable' already exists in the 'wp-config.php' file.
"""
@custom-config-file
Scenario: Add a new constant to wp-custom-config.php
Given an empty directory
And WP files
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --config-file='wp-custom-config.php'`
Then STDOUT should contain:
"""
Generated 'wp-custom-config.php' file.
"""
When I run `wp config add NEW_CONSTANT constant_value --config-file='wp-custom-config.php'`
Then STDOUT should be:
"""
Success: Added the constant 'NEW_CONSTANT' to the 'wp-custom-config.php' file with the value 'constant_value'.
"""
When I run `wp config get NEW_CONSTANT --config-file='wp-custom-config.php'`
Then STDOUT should be:
"""
constant_value
"""
Scenario: Additions can be properly placed in wp-config.php
Given a WP install
And a wp-config.php file:
"""
define( 'CONST_A', 'val-a' );
/** ANCHOR */
define( 'CONST_B', 'val-b' );
require_once( ABSPATH . 'wp-settings.php' );
"""
When I run `wp config add SOME_NAME some_value --anchor="/** ANCHOR */" --placement=before --separator="\n"`
Then STDOUT should be:
"""
Success: Added the constant 'SOME_NAME' to the 'wp-config.php' file with the value 'some_value'.
"""
And the wp-config.php file should be:
"""
define( 'CONST_A', 'val-a' );
define( 'SOME_NAME', 'some_value' );
/** ANCHOR */
define( 'CONST_B', 'val-b' );
require_once( ABSPATH . 'wp-settings.php' );
"""
When I run `wp config add ANOTHER_NAME another_value --anchor="/** ANCHOR */" --placement=after --separator="\n"`
Then STDOUT should be:
"""
Success: Added the constant 'ANOTHER_NAME' to the 'wp-config.php' file with the value 'another_value'.
"""
And the wp-config.php file should be:
"""
define( 'CONST_A', 'val-a' );
define( 'SOME_NAME', 'some_value' );
/** ANCHOR */
define( 'ANOTHER_NAME', 'another_value' );
define( 'CONST_B', 'val-b' );
require_once( ABSPATH . 'wp-settings.php' );
"""