fix(TestCase): publish the app before it boots - #92
Merged
Merged
Conversation
test(TestCase): cover the container reached from a booting callback `$this->app` was only assigned once `makeApp()` had returned, so anything running during the boot — a `beforeInit` or `beforeBooting` callback, a bootloader reaching back into the test case — found the property empty. `getApp()` and `getContainer()` then started building a second application from scratch, which recursed without end when that app ran the same callback again. Assisted-By: Claude Opus 5 (1M context)
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 was changed
TestCase::makeApp()publishes the kernel into$this->appas soon as it is created, instead of after it has booted.beforeInitorbeforeBootingcallback, a bootloader calling back into the test case — now gets the application being built when it asks forgetApp()orgetContainer().Why?
Until the boot finished,
$this->appwas stillnull, so a callback asking for the container sentgetApp()off to build a second application from scratch. That application ran the same callback, which asked again, and the recursion only ended when the stack did. Even where it survived, the container handed to the callback was not the one the test later worked with.This revives #11, which reported the problem against
1.x. The patch there no longer applies:refreshApp()is gone andinitApp()has since becomevoid.Checklist
3.xReview notes
Keep the assignment in
initApp()as well, redundant as it looks: drop it and Psalm loses the narrowing on$this->appand reports a possible null in theContainerScopeline below.Moving the boot block out of
makeApp()into its own method is the tidier shape, but it makes Psalm re-analyse that closure and surface two latent findings there,explode()with a possibly undefined offset andConfigsInterface::modify(). Both are worth their own PR rather than this one.