function DateTimeFormInjectionTest::testDatetimeSerialization
Same name in other branches
- 8.9.x core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php \Drupal\Tests\datetime\Kernel\DateTimeFormInjectionTest::testDatetimeSerialization()
- 10 core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php \Drupal\Tests\datetime\Kernel\DateTimeFormInjectionTest::testDatetimeSerialization()
- 11.x core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php \Drupal\Tests\datetime\Kernel\DateTimeFormInjectionTest::testDatetimeSerialization()
Tests custom string injection serialization.
File
-
core/
modules/ datetime/ tests/ src/ Kernel/ DateTimeFormInjectionTest.php, line 102
Class
- DateTimeFormInjectionTest
- Tests serializing a form with an injected datetime instance.
Namespace
Drupal\Tests\datetime\KernelCode
public function testDatetimeSerialization() {
$form_state = new FormState();
$form_state->setRequestMethod('POST');
$form_state->setCached();
$form_builder = $this->container
->get('form_builder');
$form_id = $form_builder->getFormId($this, $form_state);
$form = $form_builder->retrieveForm($form_id, $form_state);
$form_builder->prepareForm($form_id, $form, $form_state);
// Set up $form_state so that the form is properly submitted.
$form_state->setUserInput([
'form_id' => $form_id,
]);
$form_state->setProgrammed();
$form_state->setSubmitted();
$form_builder->processForm($form_id, $form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.