function FormTest::testInputForgery

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Form/FormTest.php \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
  2. 10 core/modules/system/tests/src/Functional/Form/FormTest.php \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
  3. 11.x core/modules/system/tests/src/Functional/Form/FormTest.php \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()

Test Form API protections against input forgery.

See also

\Drupal\form_test\Form\FormTestInputForgeryForm

File

core/modules/system/tests/src/Functional/Form/FormTest.php, line 876

Class

FormTest
Tests various form element validation mechanisms.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testInputForgery() {
    $this->drupalGet('form-test/input-forgery');
    // The value for checkboxes[two] was changed using post render to simulate
    // an input forgery.
    // @see \Drupal\form_test\Form\FormTestInputForgeryForm::postRender
    $this->drupalPostForm(NULL, [
        '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.