Skip to content

Commit d0e9246

Browse files
authored
Merge pull request #7 from austintoddj/patch-1
Assert the model has a HasOne relationship
2 parents 0108e6d + 45aedeb commit d0e9246

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/RelationshipTestHelper.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace EGALL\EloquentPHPUnit;
44

5+
use Illuminate\Database\Eloquent\Relations\HasOne;
56
use Illuminate\Database\Eloquent\Relations\HasMany;
67
use Illuminate\Database\Eloquent\Relations\MorphTo;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -72,6 +73,20 @@ public function hasMany($model, $name = null)
7273
HasMany::class, $model, $name ?: $this->getRelationshipMethodName($model, false)
7374
);
7475
}
76+
77+
/**
78+
* Assert the model has a has one relationship.
79+
*
80+
* @param string $model
81+
* @param string|null $name
82+
* @return bool
83+
*/
84+
public function hasOne($model, $name = null)
85+
{
86+
return $this->assertHasRelationship(
87+
HasOne::class, $model, $name ?: $this->getRelationshipMethodName($model, false)
88+
);
89+
}
7590

7691
/**
7792
* Assert the model has a morphs to relationship.

0 commit comments

Comments
 (0)