public function CacheableExceptionTest::testExceptions in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Http/CacheableExceptionTest.php \Drupal\Tests\Core\Http\CacheableExceptionTest::testExceptions()
@dataProvider providerTestExceptions
File
- core/
tests/ Drupal/ Tests/ Core/ Http/ CacheableExceptionTest.php, line 44
Class
- CacheableExceptionTest
- @group Http
Namespace
Drupal\Tests\Core\HttpCode
public function testExceptions($status_code, $class, $argument = NULL, $expected_headers = []) {
$cacheable_metadata = (new CacheableMetadata())
->setCacheContexts([
'route',
]);
$message = "{$class} test message";
if ($argument) {
$exception = new $class($cacheable_metadata, $argument, $message, NULL, 123);
}
else {
$exception = new $class($cacheable_metadata, $message, NULL, 123);
}
$this
->assertSame([
'route',
], $exception
->getCacheContexts());
$this
->assertSame($message, $exception
->getMessage());
$this
->assertSame($status_code, $exception
->getStatusCode());
$this
->assertSame($expected_headers, $exception
->getHeaders());
$this
->assertSame(123, $exception
->getCode());
}