function ConfigTest::testFileConfigurationPage

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest::testFileConfigurationPage()
  2. 10 core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest::testFileConfigurationPage()
  3. 11.x core/modules/system/tests/src/Functional/File/ConfigTest.php \Drupal\Tests\system\Functional\File\ConfigTest::testFileConfigurationPage()

Tests file configuration page.

File

core/modules/system/tests/src/Functional/File/ConfigTest.php, line 29

Class

ConfigTest
Tests file system configuration operations.

Namespace

Drupal\Tests\system\Functional\File

Code

public function testFileConfigurationPage() {
    $this->drupalGet('admin/config/media/file-system');
    // Set the file paths to non-default values.
    // The respective directories are created automatically
    // upon form submission.
    $fields = [
        'file_default_scheme' => 'private',
    ];
    // Check that public and private can be selected as default scheme.
    $this->assertText('Public local files served by the webserver.');
    $this->assertText('Private local files served by Drupal.');
    $this->drupalPostForm(NULL, $fields, t('Save configuration'));
    $this->assertText(t('The configuration options have been saved.'));
    foreach ($fields as $field => $value) {
        $this->assertFieldByName($field, $value);
    }
    // Remove the private path, rebuild the container and verify that private
    // can no longer be selected in the UI.
    $settings['settings']['file_private_path'] = (object) [
        'value' => '',
        'required' => TRUE,
    ];
    $this->writeSettings($settings);
    $this->rebuildContainer();
    $this->drupalGet('admin/config/media/file-system');
    $this->assertText('Public local files served by the webserver.');
    $this->assertNoText('Private local files served by Drupal.');
}

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