public function ExceptionControllerTest::test405HTML

Ensure the execute() method returns a valid response on 405 exceptions.

File

drupal/core/modules/system/lib/Drupal/system/Tests/System/ExceptionControllerTest.php, line 31

Class

ExceptionControllerTest
Tests exception controller.

Namespace

Drupal\system\Tests\System

Code

public function test405HTML() {
  $exception = new \Exception('Test exception');
  $flat_exception = FlattenException::create($exception, 405);
  $exception_controller = new ExceptionController(new ContentNegotiation());
  $response = $exception_controller
    ->execute($flat_exception, new Request());
  $this
    ->assertEqual($response
    ->getStatusCode(), 405, 'HTTP status of response is correct.');
  $this
    ->assertEqual($response
    ->getContent(), 'Method Not Allowed', 'HTTP response body is correct.');
}