I'm using sqlite for Laravel application and PHPUnit. After executing the tests the tables are removed from sqlite even though it was created :memory: for tests. So that I'm not able to login to the application with the registered user.
Note: I have used use DatabaseMigrations; statement in each test classes.
When using an Sqlite in memory database and database mirgrations it does the following
Migrate the database
Perform the test
Rollback the database migration done before the test.
PHPUnit uses the phpunit.xml file to know which database to use and it does in your case don't use the one you specified in your .env file. To be able to log in using your browser you need to run php artisan migrate and then add a user so that you can use that to log in.
Sorry, I think I'm confused, let me clear the situation a little more.
After installing I have created the user and successfully logIn and logOut.
Then I executed the test (:memory:).
If I again trying to logIn there is no record in the database, I think, when the test executed it clear the database as well.
Is there any possible way to avoid clear the database after executing the test. So that the user previously created will be remain in the database and I can login.
Since the tests is executing with the database in memory, why it is clearing the database which was for the application and how can we avoid it?