function CacheableExceptionTest::testCacheableHttpException

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

Class

CacheableExceptionTest
@group Http

Namespace

Drupal\Tests\Core\Http

Code

public function testCacheableHttpException() : void {
    $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.