function FormsTestCase::testInputForgery

Test Form API protections against input forgery.

See also

_form_test_input_forgery()

File

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

Class

FormsTestCase
@file Unit tests for the Drupal Form API.

Code

function testInputForgery() {
    $this->drupalGet('form-test/input-forgery');
    $checkbox = $this->xpath('//input[@name="checkboxes[two]"]');
    $checkbox[0]['value'] = 'FORGERY';
    $this->drupalPost(NULL, array(
        'checkboxes[one]' => TRUE,
        'checkboxes[two]' => TRUE,
    ), t('Submit'));
    $this->assertText('An illegal choice has been detected.', 'Input forgery was detected.');
}

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