Skip to content

Support fixture paths for file fields in mediaExpandEntityFieldsFixtures #629

@ericgsmith

Description

@ericgsmith

After upgrading to lastest version of Drupal Driver a lot of our tests failed due to how we were using creating media entities.

I'm raising this here as I think it can be solved here, or at least iron out a little inconsistency.

Drupal driver 2.5.0 adds a FileHandler - the release notes say that :

The Drupal 8+ FileHandler previously extended EntityReferenceHandler and tried a name-based entity lookup on raw file paths, which never produced a usable file entity

This is not correct - we have been using an entity reference value for by creating the file and then referencing it by filename which the entity reference handler correctly returned.

E.g:

    Given the following managed files:
      | path                               |
      | documents/test.docx |
    And the following media "document" exist:
      | name                      | field_media_document |
      | Test DOCX media | test.docx                          |

I was going to open an issue there, but then I noticed we were doing something completely different for our image test - there we are just passing in the path based from our fixtures, e.g.

    And the following media "image" exist:
      | name                   | field_media_image     |
      | Test PNG media | images/500x200.png |

And these tests are still passing with the new driver.

It looks like mediaExpandEntityFieldsFixtures in MediaTrait is what allows these tests to pass.

The check at https://github.com/drevops/behat-steps/blob/main/src/Drupal/MediaTrait.php#L391 updates images/500x200.png to the fixture path - but as it doesn't run apply to file fields, we can't just use documents/test.docx for field_media_document

I think the simplest is now that the driver properly supports file fields, expand that condition to also apply to image and file fields?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions