Skip to content

Commit

Permalink
Merge pull request #7 from austintoddj/patch-1
Browse files Browse the repository at this point in the history
Assert the model has a HasOne relationship
  • Loading branch information
erikgall authored Nov 8, 2016
2 parents 0108e6d + 45aedeb commit d0e9246
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/RelationshipTestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace EGALL\EloquentPHPUnit;

use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -72,6 +73,20 @@ public function hasMany($model, $name = null)
HasMany::class, $model, $name ?: $this->getRelationshipMethodName($model, false)
);
}

/**
* Assert the model has a has one relationship.
*
* @param string $model
* @param string|null $name
* @return bool
*/
public function hasOne($model, $name = null)
{
return $this->assertHasRelationship(
HasOne::class, $model, $name ?: $this->getRelationshipMethodName($model, false)
);
}

/**
* Assert the model has a morphs to relationship.
Expand Down

0 comments on commit d0e9246

Please sign in to comment.