protected function SortableTestTrait::sortableTo in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableTo()
- 9 core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableTo()
Simulates a drag on an element from one container to another.
Parameters
string $item: The HTML selector for the element to be moved.
string $from: The HTML selector for the previous container element.
null|string $to: The HTML selector for the target container.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ SortableTestTrait.php, line 38
Class
- SortableTestTrait
- Provides functions for simulating sort changes.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function sortableTo($item, $from, $to) {
$item = addslashes($item);
$from = addslashes($from);
$to = addslashes($to);
$script = <<<JS
(function (src, to) {
var sourceElement = document.querySelector(src);
var toElement = document.querySelector(to);
toElement.insertBefore(sourceElement, toElement.firstChild);
})('{<span class="php-variable">$item</span>}', '{<span class="php-variable">$to</span>}')
JS;
$options = [
'script' => $script,
'args' => [],
];
$this
->getSession()
->getDriver()
->getWebDriverSession()
->execute($options);
$this
->sortableUpdate($item, $from, $to);
}