You are here

public function CacheableExceptionTest::testCacheableHttpException in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Http/CacheableExceptionTest.php \Drupal\Tests\Core\Http\CacheableExceptionTest::testCacheableHttpException()

@covers \Drupal\Core\Http\Exception\CacheableHttpException

File

core/tests/Drupal/Tests/Core/Http/CacheableExceptionTest.php, line 32

Class

CacheableExceptionTest
@group Http

Namespace

Drupal\Tests\Core\Http

Code

public function testCacheableHttpException() {
  $exception = new CacheableHttpException((new CacheableMetadata())
    ->setCacheContexts([
    'route',
  ]), 500, 'test message', NULL, [
    'X-Drupal-Exception' => 'Test',
  ], 123);
  $this
    ->assertSame([
    'route',
  ], $exception
    ->getCacheContexts());
  $this
    ->assertSame(500, $exception
    ->getStatusCode());
  $this
    ->assertSame('test message', $exception
    ->getMessage());
  $this
    ->assertSame([
    'X-Drupal-Exception' => 'Test',
  ], $exception
    ->getHeaders());
  $this
    ->assertSame(123, $exception
    ->getCode());
}