Summer Sale! All accounts are 50% off this week.

laracoft's avatar

DatabaseMigrations and LazilyRefreshDatabase traits clash

    use \Illuminate\Foundation\Testing\DatabaseMigrations;
    use \Illuminate\Foundation\Testing\LazilyRefreshDatabase;

I used to be able to add these 2 traits together, but in L10, they now clash because both provides refreshTestDatabase(). Which one should I use and when?

0 likes
2 replies
kevinbui's avatar

Just one of those is gonna work. Pls use the LazilyRefreshDatabase trait.

When we use DatabaseMigrations, db migrations will be run for every test case in your test class.

When we use LazilyRefreshDatabase , db migrations will be run only when it is necessary.

laracoft's avatar

Do you mean LazilyRefreshDatabase can replace DatabaseMigrations for all cases? Why does DatabaseMigrations still exists if that is the case?

Please or to participate in this conversation.