function SortableTestTrait::sortableTo
Same name in other branches
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableTo()
- 10 core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableTo()
- 11.x 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.
2 calls to SortableTestTrait::sortableTo()
- LayoutBuilderTest::testLayoutBuilderUi in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderTest.php - Tests the Layout Builder UI.
- MediaLibraryTest::testConfigurationValidation in core/
modules/ ckeditor/ tests/ src/ FunctionalJavascript/ MediaLibraryTest.php - Tests validation that DrupalMediaLibrary requires media_embed filter.
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.