Skip to content

Commit 2dce842

Browse files
committed
merged branch fabpot/browserkit-client (PR #7835)
This PR was merged into the master branch. Discussion ---------- fixed Client implementation to return the right Response (closes #4475) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #4475 | License | MIT | Doc PR | symfony/symfony-docs#2549 This PR addresses #4475 by trying to minimize the BC break impact. Commits ------- 31cefc6 made some small tweaks 84ca34b alternate fix where we had accessor for the BrowerKit request/response instances 1005fd1 fixed Client implementation to return the right Response (closes #4475)
2 parents dae552f + eca51a7 commit 2dce842

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Client.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\HttpFoundation\File\UploadedFile;
1515
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\BrowserKit\Client as BaseClient;
1718
use Symfony\Component\BrowserKit\Request as DomRequest;
1819
use Symfony\Component\BrowserKit\Response as DomResponse;
@@ -49,6 +50,26 @@ public function __construct(HttpKernelInterface $kernel, array $server = array()
4950
$this->followRedirects = false;
5051
}
5152

53+
/**
54+
* {@inheritdoc}
55+
*
56+
* @return Request|null A Request instance
57+
*/
58+
public function getRequest()
59+
{
60+
return parent::getRequest();
61+
}
62+
63+
/**
64+
* {@inheritdoc}
65+
*
66+
* @return Response|null A Response instance
67+
*/
68+
public function getResponse()
69+
{
70+
return parent::getResponse();
71+
}
72+
5273
/**
5374
* Makes a request.
5475
*
@@ -100,7 +121,7 @@ protected function getScript($request)
100121
/**
101122
* Converts the BrowserKit request to a HttpKernel request.
102123
*
103-
* @param DomRequest $request A Request instance
124+
* @param DomRequest $request A DomRequest instance
104125
*
105126
* @return Request A Request instance
106127
*/
@@ -167,7 +188,7 @@ protected function filterFiles(array $files)
167188
*
168189
* @param Response $response A Response instance
169190
*
170-
* @return Response A Response instance
191+
* @return DomResponse A DomResponse instance
171192
*/
172193
protected function filterResponse($response)
173194
{

Tests/ClientTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function testDoRequest()
3535

3636
$client->request('GET', '/');
3737
$this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
38+
$this->assertInstanceOf('Symfony\Component\BrowserKit\Request', $client->getInternalRequest());
39+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Request', $client->getRequest());
40+
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse());
41+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $client->getResponse());
3842

3943
$client->request('GET', 'http://www.example.com/');
4044
$this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');

0 commit comments

Comments
 (0)