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