[FrameworkBundle] Fix calling Client::getProfile() before sending a request

This commit is contained in:
Kévin Dunglas 2019-06-25 17:43:39 +02:00
parent 675d463cf5
commit 9e6f4b2122
No known key found for this signature in database
GPG Key ID: 4D04EBEF06AAF3A6
2 changed files with 4 additions and 4 deletions

View File

@ -66,7 +66,7 @@ class Client extends BaseClient
*/
public function getProfile()
{
if (!$this->kernel->getContainer()->has('profiler')) {
if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) {
return false;
}

View File

@ -28,9 +28,9 @@ class ProfilerTest extends WebTestCase
// enable the profiler for the next request
$client->enableProfiler();
$crawler = $client->request('GET', '/profiler');
$profile = $client->getProfile();
$this->assertInternalType('object', $profile);
$this->assertFalse($client->getProfile());
$client->request('GET', '/profiler');
$this->assertInternalType('object', $client->getProfile());
$client->request('GET', '/profiler');
$this->assertFalse($client->getProfile());