Skip to content

Commit

Permalink
Fix WebTestCase (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-goncalves-kununu authored Jun 11, 2019
1 parent 3b80087 commit 3981746
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@

abstract class WebTestCase extends FixturesAwareTestCase
{
/** @var KernelBrowser $client */
private $client;

final protected function doRequest(RequestBuilder $builder): Response
{
$this->initClient();

/** @var KernelBrowser $client */
$client = static::$client;

$client->request(...$builder->build());
$this->client->request(...$builder->build());

$response = $client->getResponse();
/** @var Response $response */
$response = $this->client->getResponse();

// Since there is no content, then there is also no content-type header.
if ($response->getStatusCode() !== Response::HTTP_NO_CONTENT) {
Expand All @@ -33,8 +34,8 @@ final protected function doRequest(RequestBuilder $builder): Response

private function initClient() : void
{
if (!static::$client) {
static::createClient();
if (!$this->client) {
$this->client = static::createClient();
}
}
}

0 comments on commit 3981746

Please sign in to comment.