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

Test the submission of single and multiple values when #multiple is TRUE.

File

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

Class

FormsElementsTableSelectFunctionalTest
Test the tableselect form element for expected behavior.

Code

function testMultipleTrueSubmit() {

  // Test a submission with one checkbox checked.
  $edit = array();
  $edit['tableselect[row1]'] = TRUE;
  $this->backdropPost('form_test/tableselect/multiple-true', $edit, 'Submit');

  $this->assertText(t('Submitted: row1 = row1'), 'Checked checkbox row1');
  $this->assertText(t('Submitted: row2 = 0'), 'Unchecked checkbox row2.');
  $this->assertText(t('Submitted: row3 = 0'), 'Unchecked checkbox row3.');

  // Test a submission with multiple checkboxes checked.
  $edit['tableselect[row1]'] = TRUE;
  $edit['tableselect[row3]'] = TRUE;
  $this->backdropPost('form_test/tableselect/multiple-true', $edit, 'Submit');

  $this->assertText(t('Submitted: row1 = row1'), 'Checked checkbox row1.');
  $this->assertText(t('Submitted: row2 = 0'), 'Unchecked checkbox row2.');
  $this->assertText(t('Submitted: row3 = row3'), 'Checked checkbox row3.');

}