I have a form in the UI which I would like to submit from my unit test programmatically (i.e. not with a UiHelperTrait method) from the test. The drupalPostForm solution would be quite straightforward:

$this->drupalPostForm('/url/of/the/form', [
  'entity' => $value,
], 'Save');

But I am wondering if there is a way to achieve submitting the form with the EntityForm class's save(array $form, FormStateInterface $form_state) method? How would I be able to retrieve the $form and the $form_state values in the test class?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.