laravel-refresh-database-once maintained by ezitisitis
Author
Last update
2025/03/10 20:50
(dev-master)
License
Downloads
425
Laravel DB refresh
⚠️ Notice: This project is no longer maintained. As a replacement please use RefreshDatabase.
This package contains Trait to refresh and seed database before running test scope.
Why do you need that
When you work in local environment. It sometimes appears that you want to run tests agains clean database (for example you have record count somewhere in tests). Running each test on clear database is bad idea in general, because:
- You check only that your code works only when there is no records;
- It is insanely time consuming;
Installing
composer require --dev ezitisitis/laravel-refresh-database-once;- Add
MigrateFreshSeedOnceuse toTestCaseclass; - Congratulations, you are done.
Example:
<?php
namespace Tests;
use EzitisItIs\LaravelRefreshDatabaseOnce\MigrateFreshSeedOnce
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use MigrateFreshSeedOnce;
}