Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / File / ConfigTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\File;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests file system configuration operations.
9  *
10  * @group File
11  */
12 class ConfigTest extends BrowserTestBase {
13
14   protected function setUp(){
15     parent::setUp();
16     $this->drupalLogin ($this->drupalCreateUser(['administer site configuration']));
17   }
18
19   /**
20    * Tests file configuration page.
21    */
22   public function testFileConfigurationPage() {
23     $this->drupalGet('admin/config/media/file-system');
24
25     // Set the file paths to non-default values.
26     // The respective directories are created automatically
27     // upon form submission.
28     $file_path = $this->publicFilesDirectory;
29     $fields = [
30       'file_temporary_path' => $file_path . '/file_config_page_test/temporary',
31       'file_default_scheme' => 'private',
32     ];
33
34     // Check that public and private can be selected as default scheme.
35     $this->assertText('Public local files served by the webserver.');
36     $this->assertText('Private local files served by Drupal.');
37
38     $this->drupalPostForm(NULL, $fields, t('Save configuration'));
39     $this->assertText(t('The configuration options have been saved.'));
40     foreach ($fields as $field => $value) {
41       $this->assertFieldByName($field, $value);
42     }
43
44     // Remove the private path, rebuild the container and verify that private
45     // can no longer be selected in the UI.
46     $settings['settings']['file_private_path'] = (object) [
47       'value' => '',
48       'required' => TRUE,
49     ];
50     $this->writeSettings($settings);
51     $this->rebuildContainer();
52
53     $this->drupalGet('admin/config/media/file-system');
54     $this->assertText('Public local files served by the webserver.');
55     $this->assertNoText('Private local files served by Drupal.');
56   }
57
58 }