public function FileFieldFileExtensionsUpdateTest::testInsecureUpdatesAllowed in Drupal 9
Tests update when insecure uploads are allowed.
File
- core/
modules/ file/ tests/ src/ Functional/ Update/ FileFieldFileExtensionsUpdateTest.php, line 56
Class
Namespace
Drupal\Tests\file\Functional\UpdateCode
public function testInsecureUpdatesAllowed() {
$this
->setAllowedExtensions('php');
// Do direct database updates to avoid dependencies.
$connection = Database::getConnection();
$config = $connection
->select('config')
->fields('config', [
'data',
])
->condition('collection', '')
->condition('name', 'system.file')
->execute()
->fetchField();
$config = unserialize($config);
$config['allow_insecure_uploads'] = TRUE;
$connection
->update('config')
->fields([
'data' => serialize($config),
])
->condition('collection', '')
->condition('name', 'system.file')
->execute();
$this
->runUpdates();
$this
->assertSession()
->pageTextContains('The system is configured to allow insecure file uploads. No file field updates are necessary.');
$this
->assertSession()
->statusCodeEquals('200');
$field = FieldConfig::load('node.article.field_image');
$this
->assertSame('php', $field
->getSetting('file_extensions'));
}