As mentioned in the roadmap for 1.x (#2384241), we need tests for MVW.
Although this module would need for the biggest part JS/Browser tests, some fundamental expectations can be tested using Simpletest tests.
Here is a list of tests we want to implement and their current state:
The theme registry holds the expected entries; @see multiple_value_widget_theme_registry_alter()The UI for managing the configuration of MVW on a specific field; @see multiple_value_widget_form_field_ui_field_edit_form_alter()Generated HTML markup; @see theme_multiple_value_widget_group()API functions, at the moment only hook_multiple_value_widget_element_title_alter()Widget is present after failed validation.Adding a field item is reflected after form rebuild.- Removing a field item (where appropriate) is reflected after form rebuild.
- Multiple widgets on the same form, different fields: Adding a field item is handled properly.
- MVW for file fields.
- Multiple instances of the same field (e.g. in Paragraphs items): Adding a field item (#ajax callback) is handled properly.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff-5-7.txt | 13.82 KB | stefanos.petrakis |
| #7 | multiple_value_widget-basic_tests-2901830-7.patch | 15.28 KB | stefanos.petrakis |
Comments
Comment #2
stefanos.petrakisHere is a patch for this.
Comment #3
stefanos.petrakisComment #4
ciss commentedAwesome, thanks for this! I'd suggest we add a list of test cases we want to cover to the issue summary so that we can check those off.
Since various scenarios should be covered for each widget type individually it might make sense to create a base class and extent it for each widget type. I assume you have more experience with Web test cases than I do, so that decision is yours.
Tests that I think we should cover (bucket list, not necessarily all in one go):
Comment #5
stefanos.petrakisHere is a patch that covers some of the wanted test cases (see updated OP).
This is still WIP, reviews are welcome though along the way.
Comment #6
ciss commentedThanks, this looks like a good start! What follows is a very superficial review (I didn't review the details of the individual tests). I hope to find some time to do an in-depth review later this week.
Should be protected.
Shouldn't assertions be limited to test* methods? If this is a setup method, it should probably focus on setting things up?
Why is this neccessary?
Minor nitpick: These should be single quotes.
In general all asserts should have a proper message added, and t() should not be used for assertion messages.
As discussed on IRC I still believe we should test the various widgets individually. This should also help us pinpoint and add corner cases where features are specific to a single widget type.
Comment #7
stefanos.petrakisHere is an update, based on the last very helpful review.
Regarding the 2. point about
; although this is a valid point, the practice in core is deviating from that, and for good reason I believe. For example, TranslationTestCase::addLanguage uses asserts even though it's a configuration/helper method. And I understand this, as it is also checking some hypotheses about the configuration interface and functionality. In that sense, I think assertions in our test suite may occasionally appear inside configuration/helper methods.
Regarding the
remark; I can only agree, I am wondering if we are able to do that using Simpletest; testing the Javascript rendering+functionality is not really possible using Simpletest. Thoughts?