-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathprofile-requests.feature
More file actions
51 lines (45 loc) · 1.4 KB
/
profile-requests.feature
File metadata and controls
51 lines (45 loc) · 1.4 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
Feature: Profile HTTP requests
Scenario: Profile HTTP requests during WordPress load
Given a WP install
And that HTTP requests to https://www.apple.com/ will respond with:
"""
HTTP/1.1 200
Content-Type: text/plain
Hello world
"""
And that HTTP requests to https://www.example.com/ will respond with:
"""
HTTP/1.1 201
Content-Type: application/json
{"status":"created"}
"""
And a wp-content/mu-plugins/http-requests.php file:
"""
<?php
add_action( 'muplugins_loaded', function() {
wp_remote_get( 'https://www.apple.com/' );
wp_remote_post( 'https://www.example.com/', array( 'body' => 'test' ) );
});
"""
When I run `wp profile requests --fields=method,url`
Then STDOUT should be a table containing rows:
| method | url |
| GET | https://www.apple.com/ |
| POST | https://www.example.com/ |
And STDOUT should contain:
"""
total (2)
"""
Scenario: Profile shows no requests when none are made
Given a WP install
And a wp-content/mu-plugins/no-requests.php file:
"""
<?php
// Don't make any HTTP requests
add_filter( 'pre_http_request', '__return_false', 1 );
"""
When I run `wp profile requests --fields=method,url`
Then STDOUT should contain:
"""
total (0)
"""