Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][BrowserKit] #20815

Open
GrinWay opened this issue Mar 24, 2025 · 5 comments
Open

[Bug][BrowserKit] #20815

GrinWay opened this issue Mar 24, 2025 · 5 comments

Comments

@GrinWay
Copy link

GrinWay commented Mar 24, 2025

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

@GrinWay
Copy link
Author

GrinWay commented Mar 24, 2025

Only later I found "https://symfony.com/doc/current/testing.html#multiple-requests-in-one-test"

I apologize...

@RisingSunLight42
Copy link

Only later I found "https://symfony.com/doc/current/testing.html#multiple-requests-in-one-test"

I apologize...

@GrinWay since you found this, is your issue still relevant?

@GrinWay
Copy link
Author

GrinWay commented 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
Copy link
Member

xabbuh commented Mar 28, 2025

What do you think could be changed in the docs to make the behaviour more clear?

@GrinWay
Copy link
Author

GrinWay commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants