You are here

public function TrustedHostsTest::testFakeRequests in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/System/TrustedHostsTest.php \Drupal\system\Tests\System\TrustedHostsTest::testFakeRequests()

Tests that fake requests have the proper host configured.

See also

\Drupal\Core\Http\TrustedHostsRequestFactory

File

core/modules/system/src/Tests/System/TrustedHostsTest.php, line 66
Contains \Drupal\system\Tests\System\TrustedHostsTest.

Class

TrustedHostsTest
Tests output on the status overview page.

Namespace

Drupal\system\Tests\System

Code

public function testFakeRequests() {
  $this->container
    ->get('module_installer')
    ->install([
    'trusted_hosts_test',
  ]);
  $this->container
    ->get('router.builder')
    ->rebuild();
  $host = $this->container
    ->get('request_stack')
    ->getCurrentRequest()
    ->getHost();
  $settings['settings']['trusted_host_patterns'] = (object) array(
    'value' => array(
      '^' . preg_quote($host) . '$',
    ),
    'required' => TRUE,
  );
  $this
    ->writeSettings($settings);
  $this
    ->drupalGet('trusted-hosts-test/fake-request');
  $this
    ->assertText('Host: ' . $host);
}