Answer the question
In order to leave comments, you need to log in
Why is the database cleared after each method in PHPUnit?
I'm testing the API. Laravel 7.
In one method I register and authenticate the user.
In another, you need to work with a previously created user.
But the DB is cleared in the second method and the user is no more.
You can, of course, write everything in one method, but this is wrong.
Previously worked in PHPUnit in Laravel 5, there were no such problems.
Answer the question
In order to leave comments, you need to log in
Tests should not be dependent on each other. Nothing has changed since Laravel 5 - you either added the DatabaseMigrations or the DatabaseTransactions trait. Anyway, leave everything as it is and write normal tests.
You can use another database for testing. Google the phpunit.xml setup for testing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question