Seed a database within Laravel tests just by using a trait.
mrbenosborne/laravel-database-seed-trait is a Laravel package for seed a database within laravel tests just by using a trait..
It currently has 0 GitHub stars and 3 downloads on Packagist (latest version 1.0.1).
Install it with composer require mrbenosborne/laravel-database-seed-trait.
Discover more Laravel packages by mrbenosborne
or browse all Laravel packages to compare alternatives.
Last updated
Seed a database within Laravel tests just by using a trait.
composer require mrbenosborne/laravel-database-seed-trait
The trait will use the default seeder "DatabaseSeeder", and the default connection specified in your app config.
<?php
namespace Tests\Feature;
use DatabaseSeeder;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
class AuthControllerTest extends TestCase
{
use DatabaseMigrations;
protected function setUp(): void
{
parent::setUp();
$this->seed(DatabaseSeeder::class);
}
}
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Database\SeedDatabase;
use Tests\TestCase;
class AuthControllerTest extends TestCase
{
use DatabaseMigrations, SeedDatabase;
}