Nothing was failing. A green run printed four JSON log records — a router
warning, two readiness warnings with a driver stack trace, and two records from
LogTest — because log's default destination is stderr and these tests exercise
paths that log. Output that reads like failure on a passing run is worth
removing on its own; it also buries the failures that are real.
A new capturesFrameworkLog trait swaps a channel's logger for a Monolog
TestHandler, so the records land somewhere the test can read. Restoration hangs
off #[After] rather than tearDown(), which lets it compose with
seedsFrameworkConfig — that trait already defines one.
Swallowing the records would have been the easy fix and the wrong one, so each
is now asserted:
- Readiness deliberately withholds the database host and port from an
unauthenticated 503. That detail has to reach the operator somewhere, so the
test now pins that the log names the failing database — and, for the key
check, that it names the command that fixes it.
- A role-gated route with nobody authenticated refuses with 401 AND explains
why. Those are one behaviour: a 401 whose cause is unlogged sends an
application developer hunting through the guard chain for a route that is
simply unguarded. The test moves from expectException to try/catch so it can
assert both halves.
LogTest's two destination tests now assert the handlers rather than logging.
That is not just about noise — testStderrIsTheDefaultDestinationAndEmitsJsonLines
never asserted anything about JSON lines. It logged a record and checked only
that no file appeared, which is equally true of implementations that are broken
in several interesting ways. It now checks that the stderr destination builds
exactly one StreamHandler on php://stderr with a JsonFormatter, and that "both"
adds the file handler alongside it. Monolog opens streams lazily, so building
the handlers writes nothing and creates no file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PQDyvhd1iz7g1AF6RsCdT