class AjaxFileManagedMultipleTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php \Drupal\Tests\file\FunctionalJavascript\AjaxFileManagedMultipleTest
- 9 core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php \Drupal\Tests\file\FunctionalJavascript\AjaxFileManagedMultipleTest
Tests ajax upload to managed files.
@group file
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\Tests\file\FunctionalJavascript\AjaxFileManagedMultipleTest uses TestFileCreationTrait
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase
Expanded class hierarchy of AjaxFileManagedMultipleTest
File
- core/
modules/ file/ tests/ src/ FunctionalJavascript/ AjaxFileManagedMultipleTest.php, line 14
Namespace
Drupal\Tests\file\FunctionalJavascriptView source
class AjaxFileManagedMultipleTest extends WebDriverTestBase {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* {@inheritdoc}
*/
protected static $modules = [
'file_test',
'file',
'file_module_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests if managed file form element works well with multiple files upload.
*/
public function testMultipleFilesUpload() {
$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,
]));
}
}