ezitisitis / laravel-refresh-database-once
Fund package maintenance!
ezitisitis
Buy Me A Coffee
Requires
- php: ^8.2
- laravel/framework: ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
This package is auto-updated.
Last update: 2024-12-07 13:59:18 UTC
README
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
MigrateFreshSeedOnce
use toTestCase
class; - 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; }