You are here

function FormTest::testInputForgery in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Form/FormTest.php \Drupal\system\Tests\Form\FormTest::testInputForgery()

Test Form API protections against input forgery.

See also

_form_test_input_forgery()

File

core/modules/system/src/Tests/Form/FormTest.php, line 722
Contains \Drupal\system\Tests\Form\FormTest.

Class

FormTest
Tests various form element validation mechanisms.

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
    ->drupalPostForm(NULL, array(
    'checkboxes[one]' => TRUE,
    'checkboxes[two]' => TRUE,
  ), t('Submit'));
  $this
    ->assertText('An illegal choice has been detected.', 'Input forgery was detected.');
}