You are here

protected function TableDragTest::moveRowWithKeyboard in Drupal 8

Same name and namespace in other branches
  1. 9 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.

3 calls to TableDragTest::moveRowWithKeyboard()
TableDragTest::testKeyboardAccessibility in core/tests/Drupal/FunctionalJavascriptTests/TableDrag/TableDragTest.php
Tests accessibility through keyboard of the tabledrag functionality.
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 399

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();
}