Skip to content

fix(TestCase): publish the app before it boots - #92

Merged
roxblnfk merged 1 commit into
3.xfrom
fix/early-app-declaration
Sep 21, 2026
Merged

roxblnfk merged 1 commit into
3.xfrom
fix/early-app-declaration

Conversation

@roxblnfk

Copy link
Copy Markdown
Member

🔍 What was changed

  • TestCase::makeApp() publishes the kernel into $this->app as soon as it is created, instead of after it has booted.
  • Anything that runs during the boot — a beforeInit or beforeBooting callback, a bootloader calling back into the test case — now gets the application being built when it asks for getApp() or getContainer().
  • No public signature changes and nothing to adjust in existing tests.

Why?

Until the boot finished, $this->app was still null, so a callback asking for the container sent getApp() 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 and initApp() has since become void.

Checklist

  • How was this tested:
    • Unit tests added
    • Full suite and Psalm run locally, both unchanged against 3.x

Review notes

Keep the assignment in initApp() as well, redundant as it looks: drop it and Psalm loses the narrowing on $this->app and reports a possible null in the ContainerScope line 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 and ConfigsInterface::modify(). Both are worth their own PR rather than this one.

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)
@roxblnfk
roxblnfk merged commit 6855ca6 into 3.x Sep 21, 2026
4 of 5 checks passed
@roxblnfk
roxblnfk deleted the fix/early-app-declaration branch September 21, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant