You are here

public function ExceptionHandlingTest::test405 in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/ExceptionHandlingTest.php \Drupal\KernelTests\Core\Routing\ExceptionHandlingTest::test405()
  2. 10 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
    ->assertEqual(Response::HTTP_METHOD_NOT_ALLOWED, $response
    ->getStatusCode());
}