You are here

function FormsElementsTableSelectFunctionalTest::testMultipleTrueSubmit in Drupal 7

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

File

modules/simpletest/tests/form.test, line 928
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'), '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
    ->drupalPost('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.');
}