Cover what happens to a request before a controller sees it - #715
Merged
Conversation
The web entry point was never run by upstream CI, so its contracts are the easy ones to break. Covered: an action whose return type is not what the dispatch demands, and one missing its attribute, are both rejected — that check is what catches a whole class of breakage before it reaches a browser — while a proper one is accepted and rendered. Then what a request that goes wrong becomes: an unknown controller is a 404, an uncaught exception is a 500, a session timeout is caught separately from everything else, and a redirect a guard has already sent — the not-installed and maintenance ones — is not overwritten by the error handler afterwards. The top-level catch ends in die(), so it is exercised in a real subprocess. And the session bookkeeping the guards depend on: an expired session is restarted, first activity is recorded, an old session id is re-keyed and a failure to re-key restarts instead, and the lifetime falls back when nobody is signed in or the preset lookup fails. That needed a separate process, which is the same technique the session tests already use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
30 tests across the web and API entry points and the session bookkeeping behind them.
Why here
The web entry point was never run by upstream CI — only the mocked suites were — so its runtime contracts are the easy ones to break.
The dispatch contract
#[Action]attribute, are both rejected; a proper one is accepted and rendered. That check is what catches a whole class of breakage before it reaches a browser.What a request that goes wrong becomes
die(), so it is exercised in a real subprocess rather than skipped.The session bookkeeping the guards depend on
An expired session is restarted, first activity is recorded, an old session id is re-keyed, a failure to re-key restarts instead, and the lifetime falls back when nobody is signed in or the preset lookup fails. That needed
#[RunClassInSeparateProcess]— the same technique the session tests already use — in a sibling class rather than restructuring the existing one.Left uncovered, deliberately
Init::requireSessionContext()'s defensive throw (its own docblock says it is unreachable unless the DI wiring breaks).buildResponse()'sdefault: throw— theResponseTypeenum has exactly three cases and all three are handled.Two defects found, reported separately
Both are their own change; the first is the serious one:
Bootstrap.php:140buildsActionResponse::error($e->getMessage(), $e->getTrace()), and that trace lands in the JSONdatafield. The API entry point sends only the message. Reproduced live.Init.php:335'sini_set('session.gc_maxlifetime', …)always fails silently — the session has already been started by then, and PHP refuses that change on an active session, so the configured timeout never reaches PHP's own garbage collector.Testing
Unit: 25 green across the three classes. Integration: 12 green.