function AjaxFileManagedMultipleTest::testMultipleFilesUpload
Same name in other branches
- 9 core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php \Drupal\Tests\file\FunctionalJavascript\AjaxFileManagedMultipleTest::testMultipleFilesUpload()
- 8.9.x core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php \Drupal\Tests\file\FunctionalJavascript\AjaxFileManagedMultipleTest::testMultipleFilesUpload()
- 11.x core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php \Drupal\Tests\file\FunctionalJavascript\AjaxFileManagedMultipleTest::testMultipleFilesUpload()
Tests if managed file form element works well with multiple files upload.
File
-
core/
modules/ file/ tests/ src/ FunctionalJavascript/ AjaxFileManagedMultipleTest.php, line 35
Class
- AjaxFileManagedMultipleTest
- Tests ajax upload to managed files.
Namespace
Drupal\Tests\file\FunctionalJavascriptCode
public function testMultipleFilesUpload() : void {
$file_system = \Drupal::service('file_system');
$file_storage = \Drupal::entityTypeManager()->getStorage('file');
$page = $this->getSession()
->getPage();
$this->drupalGet(Url::fromRoute('file_module_test.managed_test', [
'multiple' => TRUE,
]));
$paths = [];
foreach (array_slice($this->drupalGetTestFiles('image'), 0, 2) as $image) {
$paths[] = $image->filename;
$page->attachFileToField('files[nested_file][]', $file_system->realpath($image->uri));
$this->assertSession()
->assertWaitOnAjaxRequest();
}
// Save entire form.
$page->pressButton('Save');
$this->assertSession()
->pageTextContains('The file ids are 1,2.');
$this->assertCount(2, $file_storage->loadByProperties([
'filename' => $paths,
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.