protected function FileFieldFileExtensionsUpdateTest::setAllowedExtensions in Drupal 9
Sets the allowed extensions on the article image field.
Parameters
string $allowed_extensions: The list of allowed extensions.
3 calls to FileFieldFileExtensionsUpdateTest::setAllowedExtensions()
- FileFieldFileExtensionsUpdateTest::testAllFileTypesAllowed in core/
modules/ file/ tests/ src/ Functional/ Update/ FileFieldFileExtensionsUpdateTest.php - Tests file fields that permit all extensions.
- FileFieldFileExtensionsUpdateTest::testInsecureUpdatesAllowed in core/
modules/ file/ tests/ src/ Functional/ Update/ FileFieldFileExtensionsUpdateTest.php - Tests update when insecure uploads are allowed.
- FileFieldFileExtensionsUpdateTest::testInsecureUpdatesNotAllowed in core/
modules/ file/ tests/ src/ Functional/ Update/ FileFieldFileExtensionsUpdateTest.php - Tests adding txt extension to field that allow insecure extensions.
File
- core/
modules/ file/ tests/ src/ Functional/ Update/ FileFieldFileExtensionsUpdateTest.php, line 90
Class
Namespace
Drupal\Tests\file\Functional\UpdateCode
protected function setAllowedExtensions(string $allowed_extensions) {
// Do direct database updates to avoid dependencies.
$connection = Database::getConnection();
$config = $connection
->select('config')
->fields('config', [
'data',
])
->condition('collection', '')
->condition('name', 'field.field.node.article.field_image')
->execute()
->fetchField();
$config = unserialize($config);
$this
->assertArrayHasKey('file_extensions', $config['settings']);
$config['settings']['file_extensions'] = $allowed_extensions;
$connection
->update('config')
->fields([
'data' => serialize($config),
])
->condition('collection', '')
->condition('name', 'field.field.node.article.field_image')
->execute();
}