Skip to content

Commit a311e25

Browse files
committed
ITT: assertEloquentBelongsTo readme added.
1 parent 9e6a353 commit a311e25

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Provides Laravel-specific testing helpers and asserts.
9898
- [assertEloquentTouchesNotEquals](#asserteloquenttouchesnotequals)
9999
- [assertEloquentHasMany](#asserteloquenthasmany)
100100
- [assertEloquentHasCreateRelationMethod](#asserteloquenthascreaterelationmethod)
101+
- [assertEloquentBelongsTo](#asserteloquentbelongsto)
101102
- [ExceptionAsserts](#exceptionasserts)
102103
- [willSeeException](#willseeexception)
103104
- [FilesystemAsserts](#filesystemasserts)
@@ -443,6 +444,28 @@ class Post extends Model
443444
}
444445
```
445446

447+
#### `assertEloquentBelongsTo()`
448+
449+
> NOTE: In order to use this assertion, you have to create model factories for both classes.
450+
451+
Checks if Eloquent model has specified `BelongsTo` relation:
452+
453+
```php
454+
$this->assertEloquentBelongsTo(Comment::class, 'post');
455+
```
456+
457+
Assuming that `Comment` class has `post` relation:
458+
459+
```php
460+
class Comment extends Model
461+
{
462+
public function post()
463+
{
464+
return $this->belongsTo(Post::class);
465+
}
466+
}
467+
```
468+
446469
### ExceptionAsserts
447470

448471
#### `willSeeException()`

0 commit comments

Comments
 (0)