Skip to content

[Tests] enableProfiler() must be called before each request #9583

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

Closed
javiereguiluz opened this issue Apr 11, 2018 · 1 comment
Closed

[Tests] enableProfiler() must be called before each request #9583

javiereguiluz opened this issue Apr 11, 2018 · 1 comment
Labels
BrowserKit bug hasPR A Pull Request has already been submitted for this issue. Status: Needs Review
Milestone

Comments

@javiereguiluz
Copy link
Member

javiereguiluz commented Apr 11, 2018

In this page (https://symfony.com/doc/current/testing/profiling.html) you can read:

Setting collect to true enables the profiler for all tests. However, if you need the profiler just in a few tests, you can keep it disabled globally and enable the profiler individually on each test by calling $client->enableProfiler().

However, it's not enough to call $client->enableProfiler() once per test. You must call it before each request (which also means, before each submit() form). Otherwise, you can't get the profiler. You can see that in the code of doRequest() in Client.php:

        if ($this->profiler) {
            $this->profiler = false; // <-- here, the value is reset

            $this->kernel->boot();
            $this->kernel->getContainer()->get('profiler')->enable();
        }
@xabbuh xabbuh added this to the 2.7 milestone Apr 12, 2018
@javiereguiluz javiereguiluz modified the milestones: 2.7, 2.8 May 28, 2018
@javiereguiluz javiereguiluz added the hasPR A Pull Request has already been submitted for this issue. label May 28, 2018
javiereguiluz added a commit that referenced this issue May 28, 2018
…iereguiluz)

This PR was merged into the 2.8 branch.

Discussion
----------

Minor tweak about enalbing the profiler in the tests

This fixes #9583 and hopefully it's easier to understand now how it works.

Commits
-------

0c53710 Minor tweak about enalbing the profiler in the tests
@javiereguiluz
Copy link
Member Author

Fixed by #9836.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BrowserKit bug hasPR A Pull Request has already been submitted for this issue. Status: Needs Review
Projects
None yet
Development

No branches or pull requests

3 participants