function DistributionProfileExistingSettingsTest::prepareEnvironment
Same name in other branches
- 9 core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php \Drupal\FunctionalTests\Installer\DistributionProfileExistingSettingsTest::prepareEnvironment()
- 8.9.x core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php \Drupal\FunctionalTests\Installer\DistributionProfileExistingSettingsTest::prepareEnvironment()
- 10 core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php \Drupal\FunctionalTests\Installer\DistributionProfileExistingSettingsTest::prepareEnvironment()
Overrides FunctionalTestSetupTrait::prepareEnvironment
File
-
core/
tests/ Drupal/ FunctionalTests/ Installer/ DistributionProfileExistingSettingsTest.php, line 34
Class
- DistributionProfileExistingSettingsTest
- Tests distribution profile support with existing settings.
Namespace
Drupal\FunctionalTests\InstallerCode
protected function prepareEnvironment() : void {
parent::prepareEnvironment();
$this->info = [
'type' => 'profile',
'core_version_requirement' => '*',
'name' => 'Distribution profile',
'distribution' => [
'name' => 'My Distribution',
'install' => [
'theme' => 'olivero',
],
],
];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/my_distribution';
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/my_distribution.info.yml", Yaml::encode($this->info));
// Pre-configure hash salt.
// Any string is valid, so simply use the class name of this test.
$this->settings['settings']['hash_salt'] = (object) [
'value' => __CLASS__,
'required' => TRUE,
];
// Pre-configure database credentials.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
$this->settings['databases']['default'] = (object) [
'value' => $connection_info,
'required' => TRUE,
];
// Use the kernel to find the site path because the site.path service should
// not be available at this point in the install process.
$site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
// Pre-configure config directories.
$this->settings['settings']['config_sync_directory'] = (object) [
'value' => $site_path . '/files/config_staging',
'required' => TRUE,
];
mkdir($this->settings['settings']['config_sync_directory']->value, 0777, TRUE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.