$form_state =
new FormState();
$form_builder =
$this->container->
get('form_builder'
);
$form_builder->
prepareForm('the_form_id',
$built,
$form_state);
$form_builder->
processForm('the_form_id',
$built,
$form_state);
$this->
render($built);
// Add in the wrapping form elements and prefix/suffix.
array_unshift($html, 'Test prefix'
);
array_unshift($html, '<form data-drupal-selector="the-form-id" action="/" method="post" id="the-form-id" accept-charset="UTF-8">'
);
// Retrieve the build ID from the rendered HTML since the string is random.
$build_id_input =
$this->
cssSelect('input[name="form_build_id"]'
)[0
]->
asXML();
$form_id_input = '<input data-drupal-selector="edit-the-form-id" type="hidden" name="form_id" value="the_form_id"/>';
$html[] = 'Test suffix';
$html[] =
$build_id_input .
$form_id_input . '</form>';
// Match the HTML to the full form element.
$this->
assertSame(implode("\n",
$html),
$this->
cssSelect('#the-form-id'
)[0
]->
asXML());
} /**
* {@inheritdoc}
*/