public function TrustedRedirectResponseTest::testCreateFromRedirectResponse in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Routing/TrustedRedirectResponseTest.php \Drupal\Tests\Core\Routing\TrustedRedirectResponseTest::testCreateFromRedirectResponse()
- 10 core/tests/Drupal/Tests/Core/Routing/TrustedRedirectResponseTest.php \Drupal\Tests\Core\Routing\TrustedRedirectResponseTest::testCreateFromRedirectResponse()
@covers ::createFromRedirectResponse @dataProvider providerCreateFromRedirectResponse
File
- core/
tests/ Drupal/ Tests/ Core/ Routing/ TrustedRedirectResponseTest.php, line 60
Class
- TrustedRedirectResponseTest
- @coversDefaultClass \Drupal\Core\Routing\TrustedRedirectResponse @group Routing
Namespace
Drupal\Tests\Core\RoutingCode
public function testCreateFromRedirectResponse($redirect_response) {
$trusted_redirect_response = TrustedRedirectResponse::createFromRedirectResponse($redirect_response);
// The trusted redirect response is always a CacheableResponseInterface instance.
$this
->assertInstanceOf(CacheableResponseInterface::class, $trusted_redirect_response);
// But it is only actually cacheable (non-zero max-age) if the redirect
// response passed to TrustedRedirectResponse::createFromRedirectResponse()
// is itself cacheable.
$expected_cacheability = $redirect_response instanceof CacheableResponseInterface ? $redirect_response
->getCacheableMetadata() : (new CacheableMetadata())
->setCacheMaxAge(0);
$this
->assertEquals($expected_cacheability, $trusted_redirect_response
->getCacheableMetadata());
}