Problem/Motivation
\Drupal\conditional_fields\ConditionalFieldsFormHelper modifies the form array with #states to provide the end-user functionality of the conditional_fields module. So it's very important. And should be tested so changes to its functionality do not cause regressions.
However, to even make ConditionalFieldsFormHelper testable, we need to make some changes to it.
Proposed resolution
Modify \Drupal\conditional_fields\ConditionalFieldsFormHelper as necessary to make its processDependentFields() and processDependeeFields() functions testable. Add tests for those functions.
Remaining tasks
Write a patch- Review and feedback
- RTBC and feedback
- Commit
User interface changes
None.
API changes
To be determined. Some methods in ConditionalFieldsFormHelper will need to change signature and visibility. However, I'll make an attempt not to break backwards compatibility, i.e.: by API additions, or giving new parameters default values so old code continues to work. Still might be worth merging this in a 2.x branch.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3206849-10--make-form-helper-testable.patch | 29.8 KB | mparker17 |
Comments
Comment #2
mparker17Here's an initial patch to test
processDependentFields()Leaving as Needs Work because I still need to test
processDependeeFields()Comment #3
socialnicheguru commentedComment #4
socialnicheguru commentedchanging it to needs work per mparkerr17's comment.
Comment #5
mparker17Here's a patch with a test for
processDependeeFields()as well.Comment #6
mparker17More unit tests!
Comment #7
mparker17Fix an unused
usestatement. And the patch filename.Comment #10
mparker17I didn't know the syntax for @covers documentation was so strict.
Comment #11
mparker17This has been committed to the 4.x branch.