diff --git a/src/Rector/MethodCall/AssertStatusToAssertMethodRector.php b/src/Rector/MethodCall/AssertStatusToAssertMethodRector.php index 4e8896ab..3c0bbe11 100644 --- a/src/Rector/MethodCall/AssertStatusToAssertMethodRector.php +++ b/src/Rector/MethodCall/AssertStatusToAssertMethodRector.php @@ -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); @@ -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(); @@ -210,6 +224,7 @@ private function updateAssertStatusCall(MethodCall $methodCall): ?MethodCall 401 => 'assertUnauthorized', 403 => 'assertForbidden', 404 => 'assertNotFound', + 405 => 'assertMethodNotAllowed', 410 => 'assertGone', 422 => 'assertUnprocessable', 500 => 'assertInternalServerError', @@ -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', diff --git a/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_illuminate_response_constants.php.inc b/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_illuminate_response_constants.php.inc index 5311b341..7990c82e 100644 --- a/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_illuminate_response_constants.php.inc +++ b/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_illuminate_response_constants.php.inc @@ -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); @@ -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(); diff --git a/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_magic_numbers.php.inc b/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_magic_numbers.php.inc index 1c08c9cc..4cf7db20 100644 --- a/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_magic_numbers.php.inc +++ b/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_magic_numbers.php.inc @@ -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); @@ -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(); diff --git a/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_symfony_response_constants.php.inc b/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_symfony_response_constants.php.inc index 6fc46afb..a386476e 100644 --- a/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_symfony_response_constants.php.inc +++ b/tests/Rector/MethodCall/AssertStatusToAssertMethodRector/Fixture/fixture_with_symfony_response_constants.php.inc @@ -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); @@ -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();