Repository navigation
Commit 16f77f8
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>1 parent 902de26 commit 16f77f8
3 files changed
Lines changed: 135 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
406 | 465 | | |
407 | 466 | | |
408 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2122 | 2122 | | |
2123 | 2123 | | |
2124 | 2124 | | |
2125 | | - | |
| 2125 | + | |
2126 | 2126 | | |
2127 | 2127 | | |
2128 | 2128 | | |
2129 | | - | |
2130 | | - | |
| 2129 | + | |
2131 | 2130 | | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
2132 | 2142 | | |
2133 | 2143 | | |
2134 | 2144 | | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
2135 | 2201 | | |
2136 | 2202 | | |
2137 | 2203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
617 | | - | |
618 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
619 | 622 | | |
620 | 623 | | |
0 commit comments