Skip to content

Commit c19f8f2

Browse files
committed
Added seedDatabase function
1 parent 968a86a commit c19f8f2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Codeception/Module/Laravel/InteractsWithEloquent.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@ public function makeMultiple(string $model, int $times, array $attributes = [],
243243
}
244244
}
245245

246+
/**
247+
* Seed a given database connection.
248+
*
249+
* @param class-string|class-string[] $seeders
250+
*/
251+
public function seedDatabase($seeders = 'Database\\Seeders\\DatabaseSeeder'): void
252+
{
253+
foreach (Arr::wrap($seeders) as $seeder) {
254+
$this->callArtisan('db:seed', ['--class' => $seeder, '--no-interaction' => true]);
255+
}
256+
}
257+
246258
/**
247259
* Checks that number of given records were found in database.
248260
* You can pass the name of a database table or the class name of an Eloquent model as the first argument.

0 commit comments

Comments
 (0)