Skip to content

[9.x] Prevent test issues with relations with the $touches property#45118

Merged
taylorotwell merged 4 commits into
laravel:9.xfrom
WendellAdriel:touches-relationship-issue
Nov 28, 2022
Merged

[9.x] Prevent test issues with relations with the $touches property#45118
taylorotwell merged 4 commits into
laravel:9.xfrom
WendellAdriel:touches-relationship-issue

Conversation

@WendellAdriel
Copy link
Copy Markdown
Member

As discussed on #45064 this is a change that will prevent the issue of an empty relationship when testing models with the $touches property defined.

TBH IDK if this is the expected behaviour so if this is not the best solution, feel free to close the PR or let me know what should I change so the PR can be accepted.

@taylorotwell taylorotwell merged commit 99aede0 into laravel:9.x Nov 28, 2022
@axlon
Copy link
Copy Markdown
Contributor

axlon commented Nov 29, 2022

@taylorotwell @WendellAdriel this PR breaks factories, it assumes a relation can only ever be a collection, but it can also be a single model.

This results in errors like:

BadMethodCallException : Call to undefined method App\Models\FooModel::isEmpty()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relationship is empty after using hasAttached() with model that $touches its parent

3 participants