8000 [BrowserKit] Various changes to the Response class by fabpot · Pull Request #29881 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[BrowserKit] Various changes to the Response class #29881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[BrowserKit] deprecated Response::getStatus() in favor of Response::g…
…etStatusCode()
  • Loading branch information
fabpot committed Jan 14, 2019
commit e8e52355d49f208df9a9b9ceac043da5b0594ece
5 changes: 5 additions & 0 deletions UPGRADE-4.3.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
UPGRADE FROM 4.2 to 4.3
=======================

BrowserKit
----------

* Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead

Config
------

Expand Down
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ UPGRADE FROM 4.x to 5.0
BrowserKit
----------

* Removed `Response::getStatus()`, use `Response::getStatusCode()` instead
* The `Client::submit()` method has a new `$serverParameters` argument.

Cache
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/BrowserKit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.3.0
-----

* Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead

4.2.0
-----

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function request(string $method, string $uri, array $parameters = array()

$this->cookieJar->updateFromResponse($this->internalResponse, $uri);

$status = $this->internalResponse->getStatus();
$status = $this->internalResponse->getStatusCode();

if ($status >= 300 && $status < 400) {
$this->redirect = $this->internalResponse->getHeader('Location');
Expand Down Expand Up @@ -599,7 +599,7 @@ public function followRedirect()

$request = $this->internalRequest;

if (\in_array($this->internalResponse->getStatus(), array(301, 302, 303))) {
if (\in_array($this->internalResponse->getStatusCode(), array(301, 302, 303))) {
$method = 'GET';
$files = array();
$content = null;
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/BrowserKit/Response.php
10000
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,17 @@ public function getContent()
* Gets the response status code.
*
* @return int The response status code
*
* @deprecated since Symfony 4.3, use getStatusCode() instead
*/
public function getStatus()
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.3, use getStatusCode() instead.', __METHOD__), E_USER_DEPRECATED);

return $this->status;
}

public function getStatusCode(): int
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent with the method name used by HttpFoundation

{
return $this->status;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function doRequest($request)
protected function filterResponse($response)
{
if ($response instanceof SpecialResponse) {
return new Response($response->getContent(), $response->getStatus(), $response->getHeaders());
return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders());
}

return $response;
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ public function testGetUri()
$this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response');
}

/**
* @group legacy
*/
public function testGetStatus()
{
$response = new Response('foo', 304);
$this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response');
}

public function testGetStatusCode()
{
$response = new Response('foo', 304);
$this->assertEquals('304', $response->getStatusCode(), '->getStatusCode() returns the status of the response');
}

public function testGetHeaders()
{
$response = new Response('foo', 200, array('foo' => 'bar'));
Expand Down
0