class DrupalSelenium2DriverTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php \Drupal\FunctionalJavascriptTests\Tests\DrupalSelenium2DriverTest
Tests the DrupalSelenium2Driver methods.
@coversDefaultClass \Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver
@group javascript
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\FunctionalJavascriptTests\Tests\DrupalSelenium2DriverTest uses \Drupal\Tests\TestFileCreationTrait, \Drupal\Tests\file\Functional\FileFieldCreationTrait implements \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of DrupalSelenium2DriverTest
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ Tests/ DrupalSelenium2DriverTest.php, line 16
Namespace
Drupal\FunctionalJavascriptTests\TestsView source
class DrupalSelenium2DriverTest extends WebDriverTestBase {
use TestFileCreationTrait;
use FileFieldCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'file',
'field_ui',
'entity_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$storage_settings = [
'cardinality' => 3,
];
$this->createFileField('field_file', 'entity_test', 'entity_test', $storage_settings);
$this->drupalLogin($this->drupalCreateUser([
'administer entity_test content',
'access content',
]));
}
/**
* Tests uploading remote files.
*/
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->assertSession()
->elementExists('xpath', '//input[@multiple]');
$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.