function EntityAutocompleteElementFormTest::testEntityAutocompleteIdInput
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php \Drupal\KernelTests\Core\Entity\Element\EntityAutocompleteElementFormTest::testEntityAutocompleteIdInput()
- 10 core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php \Drupal\KernelTests\Core\Entity\Element\EntityAutocompleteElementFormTest::testEntityAutocompleteIdInput()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php \Drupal\KernelTests\Core\Entity\Element\EntityAutocompleteElementFormTest::testEntityAutocompleteIdInput()
Tests ID input is handled correctly.
E.g. This can happen with GET form parameters.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ Element/ EntityAutocompleteElementFormTest.php, line 358
Class
- EntityAutocompleteElementFormTest
- Tests the EntityAutocomplete Form API element.
Namespace
Drupal\KernelTests\Core\Entity\ElementCode
public function testEntityAutocompleteIdInput() {
/** @var \Drupal\Core\Form\FormBuilderInterface $form_builder */
$form_builder = $this->container
->get('form_builder');
// $form = $form_builder->getForm($this);
$form_state = (new FormState())->setMethod('GET')
->setValues([
'single' => [
[
'target_id' => $this->referencedEntities[0]
->id(),
],
],
'single_no_validate' => [
[
'target_id' => $this->referencedEntities[0]
->id(),
],
],
]);
$form_builder->submitForm($this, $form_state);
$form = $form_state->getCompleteForm();
$expected_label = $this->getAutocompleteInput($this->referencedEntities[0]);
$this->assertSame($expected_label, $form['single']['#value']);
$this->assertSame($expected_label, $form['single_no_validate']['#value']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.