function CacheableExceptionTest::testCacheableHttpException

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Http/CacheableExceptionTest.php \Drupal\Tests\Core\Http\CacheableExceptionTest::testCacheableHttpException()
  2. 11.x 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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.