function FormsElementsTableSelectFunctionalTest::testMultipleFalseOptionchecker

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

File

modules/simpletest/tests/form.test, line 1007

Class

FormsElementsTableSelectFunctionalTest
Test the tableselect form element for expected behavior.

Code

function testMultipleFalseOptionchecker() {
    list($header, $options) = _form_test_tableselect_get_data();
    $form['tableselect'] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $options,
        '#multiple' => FALSE,
    );
    // Test with a valid value.
    list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array(
        'tableselect' => 'row1',
    ));
    $this->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for radio buttons.');
    // Test with an invalid value.
    list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array(
        'tableselect' => 'non_existing_value',
    ));
    $this->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for radio buttons.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.