You are here

function FormsElementsTableSelectFunctionalTest::testMultipleTrueSubmit in SimpleTest 7

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

File

tests/form.test, line 194
Unit tests for the Drupal 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
    ->drupalPost('form_test/tableselect/multiple-true', $edit, 'Submit');
  $this
    ->assertText(t('Submitted: row1 = row1'), t('Checked checkbox row1'));
  $this
    ->assertText(t('Submitted: row2 = 0'), t('Unchecked checkbox row2.'));
  $this
    ->assertText(t('Submitted: row3 = 0'), t('Unchecked checkbox row3.'));

  // Test a submission with multiple checkboxes checked.
  $edit['tableselect[row1]'] = TRUE;
  $edit['tableselect[row3]'] = TRUE;
  $this
    ->drupalPost('form_test/tableselect/multiple-true', $edit, 'Submit');
  $this
    ->assertText(t('Submitted: row1 = row1'), t('Checked checkbox row1.'));
  $this
    ->assertText(t('Submitted: row2 = 0'), t('Unchecked checkbox row2.'));
  $this
    ->assertText(t('Submitted: row3 = row3'), t('Checked checkbox row3.'));
}