function TrustedHostsTest::testRequestBags

Same name and namespace in other branches
  1. 10 core/modules/system/tests/src/Functional/System/TrustedHostsTest.php \Drupal\Tests\system\Functional\System\TrustedHostsTest::testRequestBags()
  2. 11.x core/modules/system/tests/src/Functional/System/TrustedHostsTest.php \Drupal\Tests\system\Functional\System\TrustedHostsTest::testRequestBags()

Tests that the request bags have the correct classes.

@todo Remove this when Symfony 4 is no longer supported.

See also

\Drupal\Core\Http\TrustedHostsRequestFactory

File

core/modules/system/tests/src/Functional/System/TrustedHostsTest.php, line 121

Class

TrustedHostsTest
Tests output on the status overview page.

Namespace

Drupal\Tests\system\Functional\System

Code

public function testRequestBags() {
    $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);
    foreach ([
        'request',
        'query',
        'cookies',
    ] as $bag) {
        $this->drupalGet('trusted-hosts-test/bag-type/' . $bag);
        $this->assertSession()
            ->pageTextContains('InputBag');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.