fix: morphTo when relation name is in camel case
Commit e19e10a in this PR updates existing tests to use a 'multi-word' relation for the morph relationship. This means that:
imageableis changed tohas_imagewhen passed as the$nameparameter tomorphOne()andmorphMany()Note that snake case is required here - the parent EloquentgetMorphs()method constructs the expected column names by appending '_id' and '_type' to the name that's passed.imageableis changed tohasImagewhen accessed as the relation name
That commit causes RelationsTest::testMorph() to fail, then commit c02e584 fixes the issue in line with how Eloquent's morphTo() method works, where $name variable defaults to the name of the calling function and is only snake-cased when passed to getMorphs() (reference)
Codecov Report
Merging #2318 (e26c877) into master (6aa6ad1) will not change coverage. The diff coverage is
100.00%.
@@ Coverage Diff @@
## master #2318 +/- ##
=========================================
Coverage 88.12% 88.12%
Complexity 664 664
=========================================
Files 33 33
Lines 1566 1566
=========================================
Hits 1380 1380
Misses 186 186
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/Eloquent/HybridRelations.php | 93.58% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 6aa6ad1...e26c877. Read the comment docs.
This was merged in #2498.
Thanks!