You are here

public function FormTest::testInputForgery in Drupal 9

Same name and namespace in other branches
  1. 8 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 878

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