Skip to content

Commit abeec17

Browse files
authored
add regression test (#50176)
1 parent dcf5d1d commit abeec17

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/Integration/Database/EloquentMorphEagerLoadingTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ public function testMorphLoadingMixedWithTrashedRelations()
9595
$this->assertTrue($action[1]->relationLoaded('target'));
9696
$this->assertInstanceOf(User::class, $action[1]->getRelation('target'));
9797
}
98+
99+
public function testMorphWithTrashedRelationLazyLoading()
100+
{
101+
$deletedUser = User::forceCreate(['deleted_at' => now()]);
102+
103+
$action = new Action;
104+
$action->target()->associate($deletedUser)->save();
105+
106+
// model is already set via associate and not retrieved from the database
107+
$this->assertInstanceOf(User::class, $action->target);
108+
109+
$action->unsetRelation('target');
110+
111+
$this->assertInstanceOf(User::class, $action->target);
112+
}
98113
}
99114

100115
class Action extends Model

0 commit comments

Comments
 (0)