diff --git a/README.md b/README.md index 53dedf7..85bbb88 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ Provides Laravel-specific testing helpers and asserts. - [assertEloquentTouchesNotEquals](#asserteloquenttouchesnotequals) - [assertEloquentHasMany](#asserteloquenthasmany) - [assertEloquentHasCreateRelationMethod](#asserteloquenthascreaterelationmethod) + - [assertEloquentBelongsTo](#asserteloquentbelongsto) - [ExceptionAsserts](#exceptionasserts) - [willSeeException](#willseeexception) - [FilesystemAsserts](#filesystemasserts) @@ -443,6 +444,28 @@ class Post extends Model } ``` +#### `assertEloquentBelongsTo()` + +> NOTE: In order to use this assertion, you have to create model factories for both classes. + +Checks if Eloquent model has specified `BelongsTo` relation: + +```php +$this->assertEloquentBelongsTo(Comment::class, 'post'); +``` + +Assuming that `Comment` class has `post` relation: + +```php +class Comment extends Model +{ + public function post() + { + return $this->belongsTo(Post::class); + } +} +``` + ### ExceptionAsserts #### `willSeeException()`