-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathrequests.feature
More file actions
245 lines (218 loc) · 7.15 KB
/
requests.feature
File metadata and controls
245 lines (218 loc) · 7.15 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
Feature: Requests integration with both v1 and v2
# This test downgrades to WordPress 5.8, but the SQLite plugin requires 6.0+
# WP-CLI 2.7 causes deprecation warnings on PHP 8.2
@require-mysql @less-than-php-8.2
Scenario: Composer stack with Requests v1
Given an empty directory
And a composer.json file:
"""
{
"name": "wp-cli/composer-test",
"type": "project",
"require": {
"wp-cli/wp-cli": "2.7.0",
"wp-cli/core-command": "^2",
"wp-cli/eval-command": "^2"
}
}
"""
# Note: Composer outputs messages to stderr.
And I run `composer install --no-interaction 2>&1`
When I run `vendor/bin/wp cli version`
Then STDOUT should contain:
"""
WP-CLI 2.7.0
"""
Given a WP installation
And I run `vendor/bin/wp core update --version=5.8 --force`
And I run `rm -r wp-content/themes/*`
When I run `vendor/bin/wp core version`
Then STDOUT should contain:
"""
5.8
"""
When I run `vendor/bin/wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'`
Then STDOUT should contain:
"""
object(Requests_Response)
"""
And STDOUT should contain:
"""
HTTP/1.1 200 OK
"""
And STDERR should be empty
# This test downgrades to WordPress 5.8, but the SQLite plugin requires 6.0+
@require-mysql
Scenario: Current version with WordPress-bundled Requests v1
Given a WP installation
And I run `wp core update --version=5.8 --force`
And I run `rm -r wp-content/themes/*`
When I run `wp core version`
Then STDOUT should contain:
"""
5.8
"""
When I run `wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'`
Then STDOUT should contain:
"""
object(Requests_Response)
"""
And STDOUT should contain:
"""
HTTP/1.1 200 OK
"""
And STDERR should be empty
When I run `wp plugin install duplicate-post`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""
Scenario: Current version with WordPress-bundled Requests v2
Given a WP installation
# Switch themes because twentytwentyfive requires a version newer than 6.2
# and it would otherwise cause a fatal error further down.
And I try `wp theme install twentyten`
And I try `wp theme activate twentyten`
And I run `wp core update --version=6.2 --force`
When I run `wp core version`
Then STDOUT should contain:
"""
6.2
"""
When I run `wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'`
Then STDOUT should contain:
"""
object(WpOrg\Requests\Response)
"""
And STDOUT should contain:
"""
HTTP/1.1 200 OK
"""
And STDERR should be empty
When I run `wp plugin install duplicate-post`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""
# Uses `wp db create` which is not yet supported in SQLite.
# Uses WP 6.1, which is not compatible with PHP 8.4 and causes warnings
@require-mysql @less-than-php-8.4
Scenario: Composer stack with Requests v1 pulling wp-cli/wp-cli-bundle
Given an empty directory
And a composer.json file:
"""
{
"name": "example/wordpress",
"type": "project",
"extra": {
"wordpress-install-dir": "wp",
"installer-paths": {
"content/plugins/{$name}/": [
"type:wordpress-plugin"
],
"content/themes/{$name}/": [
"type:wordpress-theme"
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
"require": {
"johnpbloch/wordpress": "6.1"
},
"require-dev": {
"wp-cli/wp-cli-bundle": "dev-main as 2.8.1"
},
"minimum-stability": "dev",
"config": {
"allow-plugins": {
"johnpbloch/wordpress-core-installer": true
}
}
}
"""
# Note: Composer outputs messages to stderr.
And I run `composer install --no-interaction 2>&1`
And a wp-cli.yml file:
"""
path: wp
"""
And an extra-config.php file:
"""
require __DIR__ . "/../vendor/autoload.php";
"""
And the {RUN_DIR}/vendor/wp-cli/wp-cli/bundle/rmccue/requests directory should exist
And the {RUN_DIR}/vendor/rmccue/requests directory should not exist
When I run `vendor/bin/wp config create --skip-check --dbname={DB_NAME} --dbuser={DB_USER} --dbpass={DB_PASSWORD} --dbhost={DB_HOST} --extra-php < extra-config.php`
Then STDOUT should be:
"""
Success: Generated 'wp-config.php' file.
"""
When I run `vendor/bin/wp config set 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 `vendor/bin/wp config set WP_DEBUG_DISPLAY true --raw`
Then STDOUT should be:
"""
Success: Added the constant 'WP_DEBUG_DISPLAY' to the 'wp-config.php' file with the raw value 'true'.
"""
When I run `vendor/bin/wp db create`
Then STDOUT should be:
"""
Success: Database created.
"""
# This can throw deprecated warnings on PHP 8.1+.
When I try `vendor/bin/wp core install --url=localhost:8181 --title=Composer --admin_user=admin --admin_password=password --admin_email=admin@example.com`
Then STDOUT should contain:
"""
Success: WordPress installed successfully.
"""
When I run `vendor/bin/wp core version`
Then STDOUT should contain:
"""
6.1
"""
# This can throw deprecated warnings on PHP 8.1+.
When I try `vendor/bin/wp eval 'var_dump( \WP_CLI\Utils\http_request( "GET", "https://example.com/" ) );'`
Then STDOUT should contain:
"""
object(Requests_Response)
"""
And STDOUT should contain:
"""
HTTP/1.1 200 OK
"""
# This can throw deprecated warnings on PHP 8.1+.
When I try `vendor/bin/wp plugin install duplicate-post --activate`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
"""
And I launch in the background `wp server --host=localhost --port=8181`
And I run `wp option set blogdescription 'Just another Composer-based WordPress site'`
When I run `curl -sS localhost:8181`
Then STDOUT should contain:
"""
Just another Composer-based WordPress site
"""
When I run `vendor/bin/wp eval 'echo COOKIEHASH;'`
And save STDOUT as {COOKIEHASH}
Then STDOUT should not be empty
When I run `vendor/bin/wp eval 'echo wp_generate_auth_cookie( 1, 32503680000 );'`
And save STDOUT as {AUTH_COOKIE}
Then STDOUT should not be empty
When I run `curl -b 'wordpress_{COOKIEHASH}={AUTH_COOKIE}' -sS localhost:8181/wp-admin/plugins.php`
Then STDOUT should contain:
"""
Plugins</h1>
"""
And STDOUT should contain:
"""
plugin=duplicate-post
"""