Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Add form helper for tests
Before
Some great people like @mlutfy have written unit tests for extension to test form interactions. However, they copied our old core test methodology of contorting some methods to be callable directly. We try not to do that in core now - preferring to imitate the user with url parameters & submitted parameters. However, we haven't had any of of our helpers available to extensions
After
This adds a new
FormTrait
which, at it's simplest allowsTechnical Details
This will probably evolve a bit over time but the basic set up is deliberately restrictive - the only way to interact with the actual form object is by calling functions on the form that have been declared as part of the api (with the
@api
annotation). However, I'm working on adding helpers to check the various form outputs - smarty variables, html, validation errors, mails but think that can be in the PR/sNote that I've added a form specific wrapper for the one form I've been working with - it makes better discoverablity for the available functions + I'm still working through where to store useful defaults for the form - so that people can submit without having to figure out all the values they need to submit
Comments