Skip to content

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

Closed
@javiereguiluz

Description

@javiereguiluz

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();
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions