Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add createOneQuietly stub #1462

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions stubs/Factory.stub
Expand Up @@ -30,6 +30,14 @@ class Factory
*/
public function createOne($attributes = []) {}

/**
* Create a single model and persist it to the database.
*
* @param array<model-property<TModel>, mixed> $attributes
* @return TModel
*/
public function createOneQuietly($attributes = []) {}

/**
* Create a collection of models and persist them to the database.
*
Expand Down
5 changes: 5 additions & 0 deletions tests/Features/ReturnTypes/ModelFactory.php
Expand Up @@ -85,6 +85,11 @@ public function testCreateOne(): Post
return Post::factory()->createOne();
}

public function testCreateOneQuietly(): Post
{
return Post::factory()->createOneQuietly();
}

/** @phpstan-return Collection<int, Post> */
public function testCreateMany(): Collection
{
Expand Down
1 change: 1 addition & 0 deletions tests/Type/data/model-factories.php
Expand Up @@ -8,6 +8,7 @@
assertType('Database\Factories\UserFactory', User::factory());
assertType('Database\Factories\UserFactory', User::factory()->new());
assertType('App\User', User::factory()->createOne());
assertType('App\User', User::factory()->createOneQuietly());
amooij marked this conversation as resolved.
Show resolved Hide resolved
assertType('Illuminate\Database\Eloquent\Collection<int, App\User>', User::factory()->createMany([]));
assertType('App\User', User::factory()->makeOne());

Expand Down