LaravelPackages.net
Acme Inc.
Toggle sidebar
vi5tar/laravel-persistingdatabase

Setup data to persist throughout a test case.

559
0
v1.1.0-beta
About vi5tar/laravel-persistingdatabase

vi5tar/laravel-persistingdatabase is a Laravel package for setup data to persist throughout a test case.. It currently has 0 GitHub stars and 559 downloads on Packagist (latest version v1.1.0-beta). Install it with composer require vi5tar/laravel-persistingdatabase. Discover more Laravel packages by vi5tar or browse all Laravel packages to compare alternatives.

Last updated

Persist data throughout a test case.

Latest Version on Packagist MIT Licensed GitHub Workflow Status Total Downloads

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);
    }
}
Comments