3 namespace Drupal\Tests\file\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests multiple file upload.
12 class MultipleFileUploadTest extends BrowserTestBase {
17 public static $modules = ['file'];
22 protected function setUp() {
25 $admin = $this->drupalCreateUser(['administer themes']);
26 $this->drupalLogin($admin);
30 * Tests multiple file field with all file extensions.
32 public function testMultipleFileFieldWithAllFileExtensions() {
33 $theme = 'test_theme_settings';
34 \Drupal::service('theme_handler')->install([$theme]);
35 $this->drupalGet("admin/appearance/settings/$theme");
38 // Create few files with non-typical extensions.
39 foreach (['file1.wtf', 'file2.wtf'] as $i => $file) {
40 $file_path = $this->root . "/sites/default/files/simpletest/$file";
41 file_put_contents($file_path, 'File with non-default extension.', FILE_APPEND | LOCK_EX);
42 $edit["files[multi_file][$i]"] = $file_path;
45 // @todo: Replace after https://www.drupal.org/project/drupal/issues/2917885
46 $this->drupalGet("admin/appearance/settings/$theme");
47 $submit_xpath = $this->assertSession()->buttonExists('Save configuration')->getXpath();
48 $client = $this->getSession()->getDriver()->getClient();
49 $form = $client->getCrawler()->filterXPath($submit_xpath)->form();
50 $client->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $edit);
52 $page = $this->getSession()->getPage();
53 $this->assertNotContains('Only files with the following extensions are allowed', $page->getContent());
54 $this->assertContains('The configuration options have been saved.', $page->getContent());
55 $this->assertContains('file1.wtf', $page->getContent());
56 $this->assertContains('file2.wtf', $page->getContent());