Skip to content

Commit 4875c05

Browse files
committed
ITT: Minor refactorings for assertEloquentHasMany.
1 parent ed917b3 commit 4875c05

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Asserts/EloquentAsserts.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ protected function assertEloquentHasMany($class, $relation)
5151
$this->assertInstanceOf(HasMany::class, $hasManyRelation);
5252

5353
$parentKey = $parent->getKeyName();
54-
$childClass = get_class($hasManyRelation->getRelated());
55-
$childKey = (new $childClass)->getKeyName();
54+
$childModel = $hasManyRelation->getRelated();
55+
$childKey = $childModel->getKeyName();
5656
$childForeignKey = method_exists($hasManyRelation, 'getForeignKeyName')
5757
? $hasManyRelation->getForeignKeyName() : last(explode('.', $hasManyRelation->getForeignKey()));
5858

59-
$children = factory($childClass, 3)->create([$childForeignKey => $parent->{$parentKey}]);
59+
$children = factory(get_class($childModel), 3)->create([$childForeignKey => $parent->{$parentKey}]);
6060

6161
$this->assertCollectionsEqual($children, $parent->{$relation}, $childKey);
6262
}

0 commit comments

Comments
 (0)