function FileFieldFileExtensionsUpdateTest::testInsecureUpdatesAllowed

Tests update when insecure uploads are allowed.

File

core/modules/file/tests/src/Functional/Update/FileFieldFileExtensionsUpdateTest.php, line 56

Class

FileFieldFileExtensionsUpdateTest
Tests file_post_update_add_txt_if_allows_insecure_extensions().

Namespace

Drupal\Tests\file\Functional\Update

Code

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'));
}

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