You are here

protected function PhpRequirementTest::setUp in Drupal 10

Overrides BrowserTestBase::setUp

File

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

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);
}