function DrupalSelenium2DriverTest::testGetRemoteFilePath
Same name in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php \Drupal\FunctionalJavascriptTests\Tests\DrupalSelenium2DriverTest::testGetRemoteFilePath()
- 10 core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php \Drupal\FunctionalJavascriptTests\Tests\DrupalSelenium2DriverTest::testGetRemoteFilePath()
- 11.x core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php \Drupal\FunctionalJavascriptTests\Tests\DrupalSelenium2DriverTest::testGetRemoteFilePath()
Tests uploading remote files.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ Tests/ DrupalSelenium2DriverTest.php, line 47
Class
- DrupalSelenium2DriverTest
- Tests the DrupalSelenium2Driver methods.
Namespace
Drupal\FunctionalJavascriptTests\TestsCode
public function testGetRemoteFilePath() {
$web_driver = $this->getSession()
->getDriver();
$file_system = \Drupal::service('file_system');
$entity = EntityTest::create();
$entity->save();
$files = array_slice($this->getTestFiles('text'), 0, 3);
$real_paths = [];
foreach ($files as $file) {
$real_paths[] = $file_system->realpath($file->uri);
}
$remote_paths = [];
foreach ($real_paths as $path) {
$remote_paths[] = $web_driver->uploadFileAndGetRemoteFilePath($path);
}
// Tests that uploading multiple remote files works with remote path.
$this->drupalGet($entity->toUrl('edit-form'));
$multiple_field = $this->xpath('//input[@multiple]')[0];
$multiple_field->setValue(implode("\n", $remote_paths));
$this->assertSession()
->assertWaitOnAjaxRequest();
$this->getSession()
->getPage()
->findButton('Save')
->click();
$entity = EntityTest::load($entity->id());
$this->assertCount(3, $entity->field_file);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.