function TrustedHostsTest::testFakeRequests
Same name in other branches
- 8.9.x core/modules/system/tests/src/Functional/System/TrustedHostsTest.php \Drupal\Tests\system\Functional\System\TrustedHostsTest::testFakeRequests()
- 10 core/modules/system/tests/src/Functional/System/TrustedHostsTest.php \Drupal\Tests\system\Functional\System\TrustedHostsTest::testFakeRequests()
- 11.x core/modules/system/tests/src/Functional/System/TrustedHostsTest.php \Drupal\Tests\system\Functional\System\TrustedHostsTest::testFakeRequests()
Tests that fake requests have the proper host configured.
See also
\Drupal\Core\Http\TrustedHostsRequestFactory
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ TrustedHostsTest.php, line 68
Class
- TrustedHostsTest
- Tests output on the status overview page.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testFakeRequests() {
$this->container
->get('module_installer')
->install([
'trusted_hosts_test',
]);
$host = $this->container
->get('request_stack')
->getCurrentRequest()
->getHost();
$settings['settings']['trusted_host_patterns'] = (object) [
'value' => [
'^' . preg_quote($host) . '$',
],
'required' => TRUE,
];
$this->writeSettings($settings);
$this->drupalGet('trusted-hosts-test/fake-request');
$this->assertSession()
->pageTextContains('Host: ' . $host);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.