function TrustedRedirectResponseTest::testCreateFromRedirectResponse
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()
- 11.x 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 <a href="/api/drupal/core%21lib%21Drupal%21Core%21Routing%21TrustedRedirectResponse.php/class/TrustedRedirectResponse/8.9.x" title="Provides a redirect response which contains trusted URLs." class="local">\Drupal\Core\Routing\TrustedRedirectResponse</a> @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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.