Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestInputForgeryForm.php
index c8a82c88b4836b889ea75b16dd209fbe782f5afe..8cdac632d09f1666fc681ac1591b5a3954f32795 100644 (file)
@@ -33,10 +33,29 @@ class FormTestInputForgeryForm extends FormBase {
       '#type' => 'submit',
       '#value' => t('Submit'),
     ];
+    $form['#post_render'][] = [static::class, 'postRender'];
 
     return $form;
   }
 
+  /**
+   * Alters the rendered form to simulate input forgery.
+   *
+   * It's necessary to alter the rendered form here because Mink does not
+   * support manipulating the DOM tree.
+   *
+   * @param string $rendered_form
+   *   The rendered form.
+   *
+   * @return string
+   *   The modified rendered form.
+   *
+   * @see \Drupal\Tests\system\Functional\Form\FormTest::testInputForgery()
+   */
+  public static function postRender($rendered_form) {
+    return str_replace('value="two"', 'value="FORGERY"', $rendered_form);
+  }
+
   /**
    * {@inheritdoc}
    */