protected function S3fsTestBase::prepareConfig in S3 File System 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Functional/S3fsTestBase.php \Drupal\Tests\s3fs\Functional\S3fsTestBase::prepareConfig()
Converts s3fs config to an array.
Parameters
\Drupal\Core\Config\Config $config: A s3fs.settings config object.
1 call to S3fsTestBase::prepareConfig()
- S3fsTestBase::setUp in tests/
src/ Functional/ S3fsTestBase.php
File
- tests/
src/ Functional/ S3fsTestBase.php, line 172
Class
- S3fsTestBase
- S3 File System Test Base.
Namespace
Drupal\Tests\s3fs\FunctionalCode
protected function prepareConfig(Config $config) {
$this->s3Config = [];
// Array to hold global settings to be written later.
$settings = [];
// Configuration for test bots here. Can be modified for local installs
// that do not use environment variables.
$config
->set('bucket', 's3fs-test-bucket')
->set('region', 'us-east-1')
->set('use_customhost', TRUE)
->set('hostname', 's3fslocalstack:4566')
->save();
$settings['settings']['s3fs.access_key'] = (object) [
'value' => 'test',
'required' => TRUE,
];
$settings['settings']['s3fs.secret_key'] = (object) [
'value' => 'test',
'required' => TRUE,
];
// Check for environment variable overrides.
if (getenv('S3FS_AWS_BUCKET')) {
$config
->set('bucket', getenv('S3FS_AWS_BUCKET'))
->save();
}
if (getenv('S3FS_AWS_REGION')) {
$config
->set('region', getenv('S3FS_AWS_REGION'))
->save();
}
if (!empty(getenv('S3FS_AWS_NO_CUSTOM_HOST'))) {
$config
->set('use_customhost', FALSE)
->save();
}
if (!empty(getenv('S3FS_AWS_CUSTOM_HOST'))) {
$config
->set('hostname', getenv('S3FS_AWS_CUSTOM_HOST'))
->save();
}
if (getenv('S3FS_AWS_KEY')) {
$settings['settings']['s3fs.access_key'] = (object) [
'value' => getenv('S3FS_AWS_KEY'),
'required' => TRUE,
];
}
if (getenv('S3FS_AWS_SECRET')) {
$settings['settings']['s3fs.secret_key'] = (object) [
'value' => getenv('S3FS_AWS_SECRET'),
'required' => TRUE,
];
}
// Set the standardized root_folder.
$rootPath = $this->remoteTestsFolder . '/' . uniqid('', TRUE);
if (!empty($config
->get('root_folder'))) {
$rootPath = $config
->get('root_folder') . '/' . $rootPath;
}
$config
->set('root_folder', $rootPath)
->save();
$this
->writeSettings($settings);
foreach ($config
->get() as $prop => $value) {
$this->s3Config[$prop] = $value;
}
}