Open
Description
I already wanted to file a bug because of unexpected behaviour I was dealing with for the last DAY
but as it turns out it just NOT documented behaviour
BrowserKit docs tells nothing about KernelBrowser::disableReboot() method
I was thinking a lot why all of my mocks just disappeared and test started using real services, real http_clients...
All the container was rebooted after the first request because of the default behaviour that HAS NOT BEEN DOCUMENTED YET
I'm crying
Activity
GrinWay commentedon Mar 24, 2025
Only later I found "https://symfony.com/doc/current/testing.html#multiple-requests-in-one-test"
I apologize...
RisingSunLight42 commentedon Mar 28, 2025
@GrinWay since you found this, is your issue still relevant?
GrinWay commentedon Mar 28, 2025
Not at all, I just used KernelBrowser::disableReboot() and as expected kernel stopped rebooting and all of my mocks remained as well
xabbuh commentedon Mar 28, 2025
What do you think could be changed in the docs to make the behaviour more clear?
GrinWay commentedon Mar 28, 2025
Wow I did not even expect that you'll ask this
First of all I'm pleasantly surprised by your question :)
Well, to tell the truth it would be nice at least to refer to this "https://symfony.com/doc/current/testing.html#multiple-requests-in-one-test" link exactly in the BrowserKit component docs in a separate small testing section.
I guess called like [Testing][Browser client default behaviour]
And in this section show that:
By default browser client is intended to be used once, because after that the whole service container will be rebooted because of the kernel rebooting it means that all of your mocked services will get lost, to avoid that and use request several times per a test call the KernelBrowser::disableReboot() method.