protected function SortableTestTrait::sortableTo in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableTo()
- 10 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()
- CKEditorIntegrationTest::testConfigurationValidation in core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ CKEditorIntegrationTest.php - Tests validation that DrupalMediaLibrary requires media_embed filter.
- LayoutBuilderTest::testLayoutBuilderUi in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderTest.php - Tests the Layout Builder UI.
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);
}