bug #32173 [FrameworkBundle] Fix calling Client::getProfile() before sending a request (dunglas)
This PR was merged into the 3.4 branch.
Discussion
----------
[FrameworkBundle] Fix calling Client::getProfile() before sending a request
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Prevent throwing an error when calling getProfile before a request has been sent.
Commits
-------
9e6f4b2122
[FrameworkBundle] Fix calling Client::getProfile() before sending a request
This commit is contained in:
commit
7cc4cabd47
@ -66,7 +66,7 @@ class Client extends BaseClient
|
|||||||
*/
|
*/
|
||||||
public function getProfile()
|
public function getProfile()
|
||||||
{
|
{
|
||||||
if (!$this->kernel->getContainer()->has('profiler')) {
|
if (null === $this->response || !$this->kernel->getContainer()->has('profiler')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ class ProfilerTest extends WebTestCase
|
|||||||
|
|
||||||
// enable the profiler for the next request
|
// enable the profiler for the next request
|
||||||
$client->enableProfiler();
|
$client->enableProfiler();
|
||||||
$crawler = $client->request('GET', '/profiler');
|
$this->assertFalse($client->getProfile());
|
||||||
$profile = $client->getProfile();
|
$client->request('GET', '/profiler');
|
||||||
$this->assertInternalType('object', $profile);
|
$this->assertInternalType('object', $client->getProfile());
|
||||||
|
|
||||||
$client->request('GET', '/profiler');
|
$client->request('GET', '/profiler');
|
||||||
$this->assertFalse($client->getProfile());
|
$this->assertFalse($client->getProfile());
|
||||||
|
Reference in New Issue
Block a user