You are here

public function ExceptionHandlingTest::test405 in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::test405()
  2. 9 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::test405()

Tests on a route with a non-supported HTTP method.

File

core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php, line 35

Class

ExceptionHandlingTest
Tests the exception handling for various cases.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function test405() {
  $request = Request::create('/router_test/test15', 'PATCH');

  /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $kernel */
  $kernel = \Drupal::getContainer()
    ->get('http_kernel');
  $response = $kernel
    ->handle($request);
  $this
    ->assertEquals(Response::HTTP_METHOD_NOT_ALLOWED, $response
    ->getStatusCode());
}