1.20.x form.test FormsElementsTableSelectFunctionalTest::testAjax()

Test presence of ajax functionality

File

modules/simpletest/tests/form.test, line 1050
Unit tests for the Backdrop Form API.

Class

FormsElementsTableSelectFunctionalTest
Test the tableselect form element for expected behavior.

Code

function testAjax() {
  $rows = array('row1', 'row2', 'row3');
  // Test checkboxes (#multiple == TRUE).
  foreach ($rows as $row) {
    $element = 'tableselect[' . $row . ']';
    $edit = array($element => TRUE);
    $result = $this->backdropPostAJAX('form_test/tableselect/multiple-true', $edit, $element);
    $this->assertFalse(empty($result), t('Ajax triggers on checkbox for @row.', array('@row' => $row)));
  }
  // Test radios (#multiple == FALSE).
  $element = 'tableselect';
  foreach ($rows as $row) {
    $edit = array($element => $row);
    $result = $this->backdropPostAjax('form_test/tableselect/multiple-false', $edit, $element);
    $this->assertFalse(empty($result), t('Ajax triggers on radio for @row.', array('@row' => $row)));
  }
}