function PhpRequirementTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/System/PhpRequirementTest.php \Drupal\Tests\system\Functional\System\PhpRequirementTest::setUp()
  2. 10 core/modules/system/tests/src/Functional/System/PhpRequirementTest.php \Drupal\Tests\system\Functional\System\PhpRequirementTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/system/tests/src/Functional/System/PhpRequirementTest.php, line 28

Class

PhpRequirementTest
Tests the output of PHP requirements on the status report.

Namespace

Drupal\Tests\system\Functional\System

Code

protected function setUp() : void {
    parent::setUp();
    $admin_user = $this->drupalCreateUser([
        'administer site configuration',
        'access site reports',
    ]);
    $this->drupalLogin($admin_user);
    // By default, Drupal installation (and BrowserTestBase) do not configure
    // trusted host patterns, which leads to an error on the status report.
    // Configure them so that the site is properly configured and so that we
    // can cleanly test the errors related to PHP versions.
    $settings['settings']['trusted_host_patterns'] = (object) [
        'value' => [
            '^' . preg_quote(\Drupal::request()->getHost()) . '$',
        ],
        'required' => TRUE,
    ];
    $this->writeSettings($settings);
}

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