public function DateTimeFormInjectionTest::testDatetimeSerialization in Drupal 10
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php \Drupal\Tests\datetime\Kernel\DateTimeFormInjectionTest::testDatetimeSerialization()
- 9 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);
}