Skip to content

Commit

Permalink
MethodNotAllowed assertion added (#112)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Clark <anthonyclark@gmail.com>
  • Loading branch information
peterfox and driftingly authored Jun 3, 2023
1 parent 701a2a6 commit b3fb8f3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Rector/MethodCall/AssertStatusToAssertMethodRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public function testNotFound()
$this->get('/')->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND);
}
public function testMethodNotAllowed()
{
$this->get('/')->assertStatus(405);
$this->get('/')->assertStatus(\Illuminate\Http\Response::HTTP_METHOD_NOT_ALLOWED);
$this->get('/')->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_METHOD_NOT_ALLOWED);
}
public function testUnprocessableEntity()
{
$this->get('/')->assertStatus(422);
Expand Down Expand Up @@ -132,6 +139,13 @@ public function testNotFound()
$this->get('/')->assertNotFound();
}
public function testMethodNotAllowed()
{
$this->get('/')->assertMethodNotAllowed();
$this->get('/')->assertMethodNotAllowed();
$this->get('/')->assertMethodNotAllowed();
}
public function testUnprocessableEntity()
{
$this->get('/')->assertUnprocessable();
Expand Down Expand Up @@ -210,6 +224,7 @@ private function updateAssertStatusCall(MethodCall $methodCall): ?MethodCall
401 => 'assertUnauthorized',
403 => 'assertForbidden',
404 => 'assertNotFound',
405 => 'assertMethodNotAllowed',
410 => 'assertGone',
422 => 'assertUnprocessable',
500 => 'assertInternalServerError',
Expand All @@ -230,6 +245,7 @@ private function updateAssertStatusCall(MethodCall $methodCall): ?MethodCall
'HTTP_UNAUTHORIZED' => 'assertUnauthorized',
'HTTP_FORBIDDEN' => 'assertForbidden',
'HTTP_NOT_FOUND' => 'assertNotFound',
'HTTP_METHOD_NOT_ALLOWED' => 'assertMethodNotAllowed',
'HTTP_GONE' => 'assertGone',
'HTTP_UNPROCESSABLE_ENTITY' => 'assertUnprocessable',
'HTTP_INTERNAL_SERVER_ERROR' => 'assertInternalServerError',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class FixtureWithIlluminateTest
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND);
}

public function testMethodNotAllowed(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_METHOD_NOT_ALLOWED);
}

public function testUnauthorized(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_UNAUTHORIZED);
Expand Down Expand Up @@ -78,6 +83,11 @@ class FixtureWithIlluminateTest
$response->assertNotFound();
}

public function testMethodNotAllowed(\Illuminate\Testing\TestResponse $response)
{
$response->assertMethodNotAllowed();
}

public function testUnauthorized(\Illuminate\Testing\TestResponse $response)
{
$response->assertUnauthorized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class FixtureTest
$response->assertStatus(404);
}

public function testMethodNotAllowed(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(405);
}

public function testUnauthorized(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(401);
Expand Down Expand Up @@ -78,6 +83,11 @@ class FixtureTest
$response->assertNotFound();
}

public function testMethodNotAllowed(\Illuminate\Testing\TestResponse $response)
{
$response->assertMethodNotAllowed();
}

public function testUnauthorized(\Illuminate\Testing\TestResponse $response)
{
$response->assertUnauthorized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class FixtureWithSymfonyResponseTest
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND);
}

public function testMethodNotAllowed(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_METHOD_NOT_ALLOWED);
}

public function testUnauthorized(\Illuminate\Testing\TestResponse $response)
{
$response->assertStatus(\Symfony\Component\HttpFoundation\Response::HTTP_UNAUTHORIZED);
Expand Down Expand Up @@ -63,6 +68,11 @@ class FixtureWithSymfonyResponseTest
$response->assertNotFound();
}

public function testMethodNotAllowed(\Illuminate\Testing\TestResponse $response)
{
$response->assertMethodNotAllowed();
}

public function testUnauthorized(\Illuminate\Testing\TestResponse $response)
{
$response->assertUnauthorized();
Expand Down

0 comments on commit b3fb8f3

Please sign in to comment.