-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathconfig-update.feature
More file actions
188 lines (157 loc) · 5.87 KB
/
config-update.feature
File metadata and controls
188 lines (157 loc) · 5.87 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
Feature: Update or add a constant or variable in wp-config.php file
Scenario: Update an existing constant in wp-config.php
Given a WP install
When I run `wp config update DB_HOST db.example.com`
Then STDOUT should be:
"""
Success: Updated the constant 'DB_HOST' in the 'wp-config.php' file with the value 'db.example.com'.
"""
When I run `wp config get DB_HOST`
Then STDOUT should be:
"""
db.example.com
"""
Scenario: Add a new constant when it doesn't exist
Given a WP install
When I run `wp config update 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: Update an existing constant then add it again
Given a WP install
When I run `wp config update TEST_CONSTANT first_value`
Then STDOUT should be:
"""
Success: Added the constant 'TEST_CONSTANT' to the 'wp-config.php' file with the value 'first_value'.
"""
When I run `wp config update TEST_CONSTANT second_value`
Then STDOUT should be:
"""
Success: Updated the constant 'TEST_CONSTANT' in the 'wp-config.php' file with the value 'second_value'.
"""
When I run `wp config get TEST_CONSTANT`
Then STDOUT should be:
"""
second_value
"""
Scenario: Update a variable with --type=variable
Given a WP install
When I run `wp config update 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 update new_variable updated_value --type=variable`
Then STDOUT should be:
"""
Success: Updated the variable 'new_variable' in the 'wp-config.php' file with the value 'updated_value'.
"""
When I run `wp config get new_variable`
Then STDOUT should be:
"""
updated_value
"""
Scenario: Update raw values in wp-config.php
Given a WP install
When I run `wp config update WP_DEBUG true --raw`
Then STDOUT should be:
"""
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'true'.
"""
When I run `wp config list WP_DEBUG --strict --format=json`
Then STDOUT should contain:
"""
{"name":"WP_DEBUG","value":true,"type":"constant"}
"""
When I run `wp config update WP_DEBUG false --raw`
Then STDOUT should be:
"""
Success: Updated the constant 'WP_DEBUG' in the 'wp-config.php' file with the raw value 'false'.
"""
When I run `wp config list WP_DEBUG --strict --format=json`
Then STDOUT should contain:
"""
{"name":"WP_DEBUG","value":false,"type":"constant"}
"""
@custom-config-file
Scenario: Update a constant in 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 update DB_HOST db.example.com --config-file='wp-custom-config.php'`
Then STDOUT should be:
"""
Success: Updated the constant 'DB_HOST' in the 'wp-custom-config.php' file with the value 'db.example.com'.
"""
When I run `wp config get DB_HOST --config-file='wp-custom-config.php'`
Then STDOUT should be:
"""
db.example.com
"""
Scenario: Ambiguous update requests throw errors
Given a WP install
When I run `wp config update SOME_NAME some_value --type=constant`
Then STDOUT should be:
"""
Success: Added the constant 'SOME_NAME' to the 'wp-config.php' file with the value 'some_value'.
"""
When I run `wp config update SOME_NAME some_value --type=variable`
Then STDOUT should be:
"""
Success: Added the variable 'SOME_NAME' to the 'wp-config.php' file with the value 'some_value'.
"""
When I run `wp config list --fields=name,type SOME_NAME --strict`
Then STDOUT should be a table containing rows:
| name | type |
| SOME_NAME | constant |
| SOME_NAME | variable |
When I try `wp config update SOME_NAME some_value`
Then STDERR should be:
"""
Error: Found both a constant and a variable 'SOME_NAME' in the 'wp-config.php' file. Use --type=<type> to disambiguate.
"""
Scenario: Update with placement options for new constants
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 update 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 update SOME_NAME updated_value --anchor="/** ANCHOR */" --placement=before --separator="\n"`
Then STDOUT should be:
"""
Success: Updated the constant 'SOME_NAME' in the 'wp-config.php' file with the value 'updated_value'.
"""
And the wp-config.php file should be:
"""
define( 'CONST_A', 'val-a' );
define( 'SOME_NAME', 'updated_value' );
/** ANCHOR */
define( 'CONST_B', 'val-b' );
require_once( ABSPATH . 'wp-settings.php' );
"""