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

  1. Write a patch
  2. Review and feedback
  3. RTBC and feedback
  4. 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.

Comments

mparker17 created an issue. See original summary.

mparker17’s picture

Here's an initial patch to test processDependentFields()

Leaving as Needs Work because I still need to test processDependeeFields()

socialnicheguru’s picture

Status: Active » Needs review
socialnicheguru’s picture

Status: Needs review » Needs work

changing it to needs work per mparkerr17's comment.

mparker17’s picture

Status: Needs work » Needs review
StatusFileSize
new19.76 KB
new12.41 KB

Here's a patch with a test for processDependeeFields() as well.

mparker17’s picture

Issue summary: View changes
StatusFileSize
new29.87 KB
new12.49 KB

More unit tests!

mparker17’s picture

StatusFileSize
new29.82 KB
new605 bytes

Fix an unused use statement. And the patch filename.

The last submitted patch, 6: 206849-6--make-form-helper-testable.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 7: 3206849-7--make-form-helper-testable.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mparker17’s picture

Status: Needs work » Needs review
StatusFileSize
new29.8 KB
new5.67 KB

I didn't know the syntax for @covers documentation was so strict.

mparker17’s picture

Version: 8.x-1.x-dev » 4.x-dev
Status: Needs review » Fixed

This has been committed to the 4.x branch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.