Skip to content

Commit

Permalink
add regression test (#50176)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuernbergerA authored Feb 21, 2024
1 parent dcf5d1d commit abeec17
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Integration/Database/EloquentMorphEagerLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ public function testMorphLoadingMixedWithTrashedRelations()
$this->assertTrue($action[1]->relationLoaded('target'));
$this->assertInstanceOf(User::class, $action[1]->getRelation('target'));
}

public function testMorphWithTrashedRelationLazyLoading()
{
$deletedUser = User::forceCreate(['deleted_at' => now()]);

$action = new Action;
$action->target()->associate($deletedUser)->save();

// model is already set via associate and not retrieved from the database
$this->assertInstanceOf(User::class, $action->target);

$action->unsetRelation('target');

$this->assertInstanceOf(User::class, $action->target);
}
}

class Action extends Model
Expand Down

0 comments on commit abeec17

Please sign in to comment.