function SuperUserAccessInstallTest::prepareEnvironment

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Installer/SuperUserAccessInstallTest.php \Drupal\FunctionalTests\Installer\SuperUserAccessInstallTest::prepareEnvironment()

Prepares the current environment for running the test.

Also sets up new resources for the testing environment, such as the public filesystem and configuration directories.

Overrides FunctionalTestSetupTrait::prepareEnvironment

File

core/tests/Drupal/FunctionalTests/Installer/SuperUserAccessInstallTest.php, line 37

Class

SuperUserAccessInstallTest
Tests superuser access and the installer.

Namespace

Drupal\FunctionalTests\Installer

Code

protected function prepareEnvironment() {
  parent::prepareEnvironment();
  $info = [
    'type' => 'profile',
    'core_version_requirement' => '*',
    'name' => 'Superuser testing profile',
  ];
  // File API functions are not available yet.
  $path = $this->siteDirectory . '/profiles/superuser';
  mkdir($path, 0777, TRUE);
  file_put_contents("{$path}/superuser.info.yml", Yaml::encode($info));
  file_put_contents("{$path}/superuser.install", $this->getProvidedData()['install_code']);
  $services = Yaml::decode(file_get_contents(DRUPAL_ROOT . '/sites/default/default.services.yml'));
  $services['parameters']['security.enable_super_user'] = $this->getProvidedData()['super_user_policy'];
  file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/services.yml', Yaml::encode($services));
}

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