function FormsElementsTableSelectFunctionalTest::testAjax in Drupal 7
Test presence of ajax functionality
File
- modules/
simpletest/ tests/ form.test, line 1030 - Unit tests for the Drupal 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
->drupalPostAJAX('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
->drupalPostAjax('form_test/tableselect/multiple-false', $edit, $element);
$this
->assertFalse(empty($result), t('Ajax triggers on radio for @row.', array(
'@row' => $row,
)));
}
}