Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
DateTimeItemTest is not a valid test. The formats used for the field configuration do not match each other. In addition, the actual values stored aren't valid per the defined formats.
Proposed resolution
Fix the test.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2832264-02.patch | 8.16 KB | mpdonadio |
Comments
Comment #2
mpdonadioHere is a port of the test changes from #2824717-15: Add a format constraint to DateTimeItem to provide REST error message w/o any of the constraint tests. Passes locally.
Comment #3
mpdonadioThe diff on this is a little hard to read to see what is really wrong. It is best to read the file before and after the patch.
Comment #4
jhedstromThis is looking good. Just one question really:
Do we need to check the
[0]
bit? If so, should we check it below as well where checking the updated value?Lol, machine name for date!
Comment #5
mpdonadio#4-1, if you look at the before/after for the whole class, that hunk makes more sense. The current test does that; the changes mirror how the existing testing is done, but make them valid and creates separate test methods for date+time and date-only variants. The first blip with [0] is testing that everything is created properly w/ the right interfaces (the list interface and the item interface) and that you can set both ways. Below, the blip w/o the [0] is just testing that you can change the values.
I'd be fine w/ adding some additional assertions, but I think they are overkill. We don't test all of the ways we can set/get field values because that is not the responsibility of the class under test, the parent class handles that magic.
Comment #6
mpdonadioI am downgrading this. It is not major, and the parent issue has been committed.
Comment #8
jhedstromre #5 thanks for the clarification. I think this is good to go.
Comment #9
xjmThe 8.2.x retest failed and is no longer valid anyway, so I attached an 8.3.x test run.
Comment #10
xjmHm why are we removing the Z here? Is this what's being discussed in #4 and #5?
Everything else in the patch seemed like valid refactoring of and additions to the test coverage; just that caught me out.
Comment #11
xjmNR for #10 (at least a confirmation that it's intentional and brief explanation of why). I read the updated test as a whole and did not see an explicit reason one way or the other (though everything else looked good).
Comment #12
mpdonadio#10, we do not store the timezone with the timestamp. See #2716891: DateTimeIso8601::setDateTime() vs. DateTimeItem::schema(): (at least) one of them is broken. The format for date+time is
Y-m-d\TH:i:s
. So the value that we use in the test should match. The fact that it will currently work with the 'Z' should be addressed by #2824717: Add a format constraint to DateTimeItem to provide REST error message (a lot of the test changes are unneeded in that patch if this one lands first, I would almost call that one soft-blocked by this).Comment #13
mpdonadioAnd as another note, I would really prefer for this to land before #2824717: Add a format constraint to DateTimeItem to provide REST error message. The constraint issue is going to be hard to get done for two reasons (getting rid of form validation / making work with daterange, and also because of when constraints get called when saving from widgets and how the datelist widget works). I think having a valid test is more important right now.
Comment #14
jhedstromI think #12 and #13 have addressed #10, so back to RTBC.
Comment #17
xjmOkay, great, thanks for the clarification! Committed to 8.4.x and backported to 8.3.x as a test improvement to an individual test.