function TableDragTest::moveRowWithKeyboard

Same name in other branches
  1. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::moveRowWithKeyboard()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::moveRowWithKeyboard()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php \Drupal\FunctionalJavascriptTests\TableDrag\TableDragTest::moveRowWithKeyboard()

Moves a row through the keyboard.

Parameters

\Behat\Mink\Element\NodeElement $row: The row to move.

string $arrow: The arrow button to use to move the row. Either one of 'left', 'right', 'up' or 'down'.

int $repeat: (optional) How many times to press the arrow button. Defaults to 1.

4 calls to TableDragTest::moveRowWithKeyboard()
TableDragTest::assertKeyboardAccessibility in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Asserts accessibility through keyboard of a test draggable table.
TableDragTest::testNestedDraggableTables in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Tests nested draggable tables through keyboard.
TableDragTest::testRootLeafDraggableRowsWithKeyboard in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Tests the root and leaf behaviors for rows.
TableDragTest::testTableDragChangedWarning in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Tests the warning that appears upon making changes to a tabledrag table.

File

core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php, line 588

Class

TableDragTest
Tests draggable table.

Namespace

Drupal\FunctionalJavascriptTests\TableDrag

Code

protected function moveRowWithKeyboard(NodeElement $row, $arrow, $repeat = 1) {
    $keys = [
        'left' => 37,
        'right' => 39,
        'up' => 38,
        'down' => 40,
    ];
    if (!isset($keys[$arrow])) {
        throw new \InvalidArgumentException('The arrow parameter must be one of "left", "right", "up" or "down".');
    }
    $key = $keys[$arrow];
    $handle = $row->find('css', 'a.tabledrag-handle');
    $handle->focus();
    for ($i = 0; $i < $repeat; $i++) {
        $this->markRowHandleForDragging($handle);
        $handle->keyDown($key);
        $handle->keyUp($key);
        $this->waitUntilDraggingCompleted($handle);
    }
    $handle->blur();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.