function TrustedRedirectResponseTest::testSetTargetUrlWithUntrustedUrl
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Routing/TrustedRedirectResponseTest.php \Drupal\Tests\Core\Routing\TrustedRedirectResponseTest::testSetTargetUrlWithUntrustedUrl()
- 10 core/tests/Drupal/Tests/Core/Routing/TrustedRedirectResponseTest.php \Drupal\Tests\Core\Routing\TrustedRedirectResponseTest::testSetTargetUrlWithUntrustedUrl()
- 11.x core/tests/Drupal/Tests/Core/Routing/TrustedRedirectResponseTest.php \Drupal\Tests\Core\Routing\TrustedRedirectResponseTest::testSetTargetUrlWithUntrustedUrl()
@covers ::setTargetUrl
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ TrustedRedirectResponseTest.php, line 33
Class
- TrustedRedirectResponseTest
- @coversDefaultClass \Drupal\Core\Routing\TrustedRedirectResponse @group Routing
Namespace
Drupal\Tests\Core\RoutingCode
public function testSetTargetUrlWithUntrustedUrl() {
$request_context = new RequestContext();
$request_context->setCompleteBaseUrl('https://www.drupal.org');
$container = new ContainerBuilder();
$container->set('router.request_context', $request_context);
\Drupal::setContainer($container);
$redirect_response = new TrustedRedirectResponse('/example');
$this->expectException(\InvalidArgumentException::class);
$redirect_response->setTargetUrl('http://evil-url.com/example');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.