Skip to content

[9.x] change status code assertions on TestResponseTest. #44661

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
47 changes: 8 additions & 39 deletions tests/Testing/TestResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,7 @@ public function testAssertDontSeeTextEscapedCanFail()

public function testAssertOk()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');
$statusCode = 200;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand All @@ -503,11 +499,7 @@ public function testAssertOk()

public function testAssertCreated()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');
$statusCode = 201;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand All @@ -519,10 +511,7 @@ public function testAssertCreated()

public function testAssertNotFound()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);
$this->expectExceptionMessage('Expected response status code');
$statusCode = 404;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand All @@ -534,11 +523,7 @@ public function testAssertNotFound()

public function testAssertForbidden()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');
$statusCode = 403;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand All @@ -550,11 +535,7 @@ public function testAssertForbidden()

public function testAssertUnauthorized()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');
$statusCode = 401;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand All @@ -566,11 +547,7 @@ public function testAssertUnauthorized()

public function testAssertUnprocessable()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');
$statusCode = 422;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand All @@ -594,11 +571,7 @@ public function testAssertServerError()

public function testAssertNoContentAsserts204StatusCodeByDefault()
{
$statusCode = 500;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');
$statusCode = 204;

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
Expand Down Expand Up @@ -642,13 +615,9 @@ public function testAssertNoContentAssertsEmptyContent()

public function testAssertStatus()
{
$statusCode = 500;
$statusCode = 401;
$expectedStatusCode = 401;

$this->expectException(AssertionFailedError::class);

$this->expectExceptionMessage('Expected response status code');

$baseResponse = tap(new Response, function ($response) use ($statusCode) {
$response->setStatusCode($statusCode);
});
Expand Down