FormsElementsTableSelectFunctionalTest::testMultipleTrueOptionchecker

7 form.test FormsElementsTableSelectFunctionalTest::testMultipleTrueOptionchecker()
8 form.test FormsElementsTableSelectFunctionalTest::testMultipleTrueOptionchecker()

Test the whether the option checker gives an error on invalid tableselect values for checkboxes.

File

modules/simpletest/tests/form.test, line 834
Unit tests for the Drupal Form API.

Code

function testMultipleTrueOptionchecker() {

  list($header, $options) = _form_test_tableselect_get_data();

  $form['tableselect'] = array(
    '#type' => 'tableselect', 
    '#header' => $header, 
    '#options' => $options,
  );

  // Test with a valid value.
  list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array('tableselect' => array('row1' => 'row1')));
  $this->assertFalse(isset($errors['tableselect']), t('Option checker allows valid values for checkboxes.'));

  // Test with an invalid value.
  list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array('tableselect' => array('non_existing_value' => 'non_existing_value')));
  $this->assertTrue(isset($errors['tableselect']), t('Option checker disallows invalid values for checkboxes.'));

}
Login or register to post comments