[#760] Expanded fixture paths for file and image fields in subdirectories. - #764
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: 8 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour. WalkthroughNested fixture paths now resolve to absolute paths under Mink’s fixture directory. The shared resolver validates file existence and directory boundaries. Field values, compound ChangesDrupal fixture path resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change enables file and image fixtures in nested directories while preserving handling for stream URIs, absolute paths, missing files, and traversal attempts. No actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant API scenario
participant HelperTrait
participant helperResolveFixtureFile
participant FileHandler
API scenario->>HelperTrait: Provide nested fixture path
HelperTrait->>helperResolveFixtureFile: Validate and resolve path
helperResolveFixtureFile-->>HelperTrait: Return absolute fixture path
HelperTrait->>FileHandler: Pass resolved path for upload
FileHandler-->>API scenario: Create field value
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue Full details: Docstring CoverageExplanation Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #764 +/- ##
==========================================
+ Coverage 97.47% 97.53% +0.06%
==========================================
Files 52 52
Lines 4548 4552 +4
==========================================
+ Hits 4433 4440 +7
+ Misses 115 112 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #760
Summary
Fixture file paths for
fileandimagefields on entity stubs stopped expanding as soon as the value contained a path separator, so a value likeimages/500x200.pngwas passed straight through to drupal-driver and failed withfile_get_contents(images/500x200.png): Failed to open streaminstead of being rewritten to an absolute path under the Minkfiles_path. Only bare filenames such as500x200.pngworked.HelperTrait::helperExpandFixtureFiles()andhelperExpandCompoundCellFixtures()now resolve the value relative to the fixtures directory through a newhelperResolveFixtureFile()method instead of rejecting anything containing a separator.ContentTraitis updated to describe the same behaviour for node file/image fields.Changes
src/Drupal/HelperTrait.php: replaced the separator-rejection check inhelperExpandFixtureFiles()andhelperExpandCompoundCellFixtures()with a call to the newhelperResolveFixtureFile(), which treats the value as relative to the fixtures directory, leaves stream URIs (public://...) and absolute paths for drupal-driver to resolve, and confirms the resolved realpath stays inside the fixtures directory so a../value cannot escape it.src/Drupal/ContentTrait.php: updated the docblock on the node file/image expansion method to describe subdirectory paths alongside bare filenames.tests/phpunit/src/Drupal/HelperTraitTest.php: extendedcreateFixtureFiles()to create parent directories as needed, and added cases covering a subdirectory fixture, a nested multi-level fixture, a multi-value list of subdirectory fixtures, a missing subdirectory fixture, a stream URI, an absolute path, and a../traversal attempt.tests/behat/features/drupal_content.featureandtests/behat/features/drupal_media.feature: added scenarios that create a node and a media entity with afile/imagefield value pointing at a fixture in a subdirectory.Before / After
Summary
fileandimagefields.target_idvalues.Critical
CONTRIBUTING.mdcontent was not available.