Repository navigation
Tags: wp-cli/wp-cli-tests
Tags
Make the PHP built-in web server step work without server-command (#363) * Make the PHP built-in web server step work without server-command `start_php_server()` always passed `{RUN_DIR}/vendor/wp-cli/server-command/router.php` as the router script, but no built-in step puts wp-cli/server-command into the run directory (`Given a WP installation with Composer` only requires WordPress core). PHP then fails every request with a fatal error while trying to open the router, and with `display_errors=On` that error page is even served with a 200 status, so a scenario serving static files gets an error page instead of its fixture and a missing file never yields a 404. Only pass the router when it actually exists, looking in the run directory first and then in the vendor directory of the project under test. Without a router, PHP's built-in web server serves the directory as-is, which is what a plain directory of files needs. The `Then the HTTP status code should be` step relied on the Requests v1 class, which WP-CLI no longer autoloads, so it failed with a fatal error before the request was made. Use whichever Requests version WP-CLI ships. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019g8sd6U4w59qiQW7LTt1jG * Honor a custom Composer vendor-dir and assert the served response Look up the server-command router in the vendor directory configured in the run directory's composer.json, so that a WP installation with a custom vendor directory is covered as well. Extend the scenarios to check the response body and a real 404, so that they fail against the old behavior of serving PHP's fatal-error page with a 200 status. PHP's built-in web server falls back to index.html for unknown paths when it exists, so the 404 case lives in its own scenario without an index file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019g8sd6U4w59qiQW7LTt1jG * Avoid $argv in the feature file fixture PHPStan flags `$argv` as possibly undefined in the PHP blocks of feature files, so read the argument from `$_SERVER['argv']` instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019g8sd6U4w59qiQW7LTt1jG * Use get_headers() in the feature file fixture PHP 8.5 deprecates the `$http_response_header` variable, and the deprecation notice on STDERR fails the `I run` step. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019g8sd6U4w59qiQW7LTt1jG --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
PreviousNext