Skip to content

Commit bf2ebf7

Browse files
committed
ITT: assertEloquentHasCreateRelationMethod readme added.
1 parent 8a0cac9 commit bf2ebf7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Provides Laravel-specific testing helpers and asserts.
9797
- [assertEloquentTouchesEquals](#asserteloquenttouchesequals)
9898
- [assertEloquentTouchesNotEquals](#asserteloquenttouchesnotequals)
9999
- [assertEloquentHasMany](#asserteloquenthasmany)
100+
- [assertEloquentHasCreateRelationMethod](#asserteloquenthascreaterelationmethod)
100101
- [ExceptionAsserts](#exceptionasserts)
101102
- [willSeeException](#willseeexception)
102103
- [FilesystemAsserts](#filesystemasserts)
@@ -408,6 +409,26 @@ Checks if Eloquent model has specified `HasMany` relation:
408409
$this->assertEloquentHasMany(Post::class, 'comments');
409410
```
410411

412+
#### `assertEloquentHasCreateRelationMethod()`
413+
414+
> NOTE: In order to use this assertion, you have to create model factories for both classes.
415+
416+
Checks if Eloquent model has create method for specified `HasMany` relation:
417+
418+
```php
419+
$this->assertEloquentHasCreateRelationMethod(Post::class, 'comments');
420+
421+
// Assuming that `Post` class has `createComment` method
422+
423+
class Post extends Model
424+
{
425+
public function createComment(array $comment)
426+
{
427+
return $this->comments()->create($comment);
428+
}
429+
}
430+
```
431+
411432
### ExceptionAsserts
412433

413434
#### `willSeeException()`

0 commit comments

Comments
 (0)