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.

CommentFileSizeAuthor
#2 2903332.patch10.44 KBamateescu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amateescu created an issue. See original summary.

amateescu’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
10.44 KB

Here'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 :)

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

💎correction!


I wanted to find flaws in #2 (via compare old instance -> field and new field -> field_storage replacment), but I could not.

  • catch committed 145d1ea on 8.5.x
    Issue #2903332 by amateescu: Regression: lost test coverage for handling...

  • catch committed dbf46f5 on 8.4.x
    Issue #2903332 by amateescu: Regression: lost test coverage for handling...

catch credited catch.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Very good find, glad it still passes now it's restored.

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

Status: Fixed » Closed (fixed)

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