vi5tar / laravel-persistingdatabase
Setup data to persist throughout a test case.
Installs: 559
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/vi5tar/laravel-persistingdatabase
Requires
- laravel/framework: ^6.0||^7.0||^8.0||^9.0
Requires (Dev)
This package is auto-updated.
Last update: 2025-10-28 22:33:38 UTC
README
This package provides a trait that can be used on a Illuminate\Foundation\Testing\TestCase to setup data
once for the tests in that TestCase.
Notice:
This is an alternative to Illuminate\Foundation\Testing\RefreshDatabase. Use one or the other depending on
the needs of the tests.
Installation
Install via composer:
composer require vi5tar/laravel-persistingdatabase
Usage
use ArticleSeeder; use PostSeeder; use Tests\TestCase; use Vi5tar\PersistingDatabase; class ExampleTest extends TestCase { use PersistingDatabase; public function setupDb(): void { $this->seed([ ArticleSeeder::class, PostSeeder::class ]); } /** * A basic feature test example. * * @return void */ public function articleIndexTest() { $response = $this->get('/articles'); $response->assertStatus(200); } /** * A basic feature test example. * * @return void */ public function postIndexTest() { $response = $this->get('/posts'); $response->assertStatus(200); } }