function TableDragTest::moveRowWithKeyboard

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

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.