function FormTest::testInputForgery

Same name in other branches
  1. 8.9.x 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()

Tests Form API protections against input forgery.

See also

\Drupal\form_test\Form\FormTestInputForgeryForm

File

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

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->submitForm([
        'checkboxes[one]' => TRUE,
        'checkboxes[two]' => TRUE,
    ], 'Submit');
    $this->assertSession()
        ->pageTextContains('An illegal choice has been detected.');
}

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