function FormTest::testInputForgery

Test Form API protections against input forgery.

See also

_form_test_input_forgery()

File

drupal/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php, line 618
Definition of Drupal\system\Tests\Form\FormTest.

Class

FormTest

Namespace

Drupal\system\Tests\Form

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.');
}