From 58ab7d33bc5f5523c194dcd63b8eb45a6518999f Mon Sep 17 00:00:00 2001 From: Jarek Tkaczyk Date: Tue, 17 Jul 2018 13:13:17 +0800 Subject: [PATCH] allow relation without related model (morphTo case) --- src/EloquentSuite.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EloquentSuite.php b/src/EloquentSuite.php index 6d31475..ab5879c 100644 --- a/src/EloquentSuite.php +++ b/src/EloquentSuite.php @@ -48,11 +48,11 @@ trait EloquentSuite * * @param string $model Classname of the model under test * @param string $relation Relation method (belongsTo, hasMany etc) - * @param string $related Classname of the related model + * @param string|null $related Classname of the related model * @param ...string $params Optional params for the relation * @return \PHPUnit\Framework\MockObject\MockObject[] */ - public function createRelationMock(string $model, string $relation, string $related, ...$params) : MockObject + public function createRelationMock(string $model, string $relation, string $related = null, ...$params) : MockObject { return $this->createRelationChainMock($model, $relation, $related, ...$params)[0]; } @@ -82,11 +82,11 @@ public function createRelationMock(string $model, string $relation, string $rela * * @param string $model Classname of the model under test * @param string $relation Relation method (belongsTo, hasMany etc) - * @param string $related Classname of the related model + * @param string|null $related Classname of the related model * @param ...string $params Optional params for the relation * @return [\PHPUnit\Framework\MockObject\MockObject, \Mockery\MockInterface] */ - public function createRelationChainMock(string $model, string $relation, string $related, ...$params) : array + public function createRelationChainMock(string $model, string $relation, string $related = null, ...$params) : array { if (!array_key_exists($relation, self::$eloquent_relations)) { $this->fail('Unknown relation provided: ' . $relation);