Problem/Motivation
While writing a test for #2322421: Recoverable fatal error: Object of class Drupal\Core\Field\FieldItemList I noticed a very peculiar line in ImageFieldDefaultImagesTest
:
foreach (['field', 'field', 'field2', 'field_new', 'field_new'] as $image_target) {
Surely someone who can write a test knows that duplicating array keys doesn't lead to anything useful, so I dug a bit in the history of that file and it looks like #2312093: Rename FieldInstanceConfig to FieldConfig is the culprit. The original line looked like this in D7:
foreach (array('field', 'instance', 'instance2', 'field_new', 'instance_new') as $image_target) {
which, in D8 terms, means: ['field_storage', 'field', 'field2', 'field_storage_new', 'field_new']
.
The consequence is that we've lost half of the test coverage from that test class, the half that deals with checking different default images being set on the field storage config vs. field confg and the fallback to the field storage setting if the field doesn't specify a default image.
Proposed resolution
Let's fix it :)
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2903332.patch | 10.44 KB | amateescu |
Comments
Comment #2
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedHere's a patch that cleans up after #2312093: Rename FieldInstanceConfig to FieldConfig.
We can't have a "test only" patch because we're only dealing with a test file :)
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commented💎correction!
I wanted to find flaws in #2 (via compare old
instance -> field
and newfield -> field_storage
replacment), but I could not.Comment #7
catchVery good find, glad it still passes now it's restored.
Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!