dist-archive-command/features/profile-requests.feature
Pascal Birchler 1682ae13a6
Update features/profile-requests.feature
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-15 14:45:09 +02:00

53 lines
1.5 KiB
Gherkin

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', function() {
return new WP_Error( 'http_requests_disabled', 'HTTP requests are disabled during this test.' );
}, 1 );
"""
When I run `wp profile requests --fields=method,url`
Then STDOUT should contain:
"""
total (0)
"""