N
N
Northern Lights2021-07-16 01:10:07
Laravel
Northern Lights, 2021-07-16 01:10:07

How to test inserts into a database?

There are tests that are loaded into the database - this is one type of test.
Accordingly, in the same class, you need to do some checks, for example, how many records have been added:

function testUpdate(){}

function testCountRows(){}


At the same time, the database does not need to be littered - it is necessary to somehow clean it up.
The Laravel trait DatabaseTransactions is executed on every test (method) and this is not a solution - the testCountRows method will no longer show anything, the transaction will be rolled back.

How to do the right thing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tolmachev, 2021-07-16
@php666

https://laravel.com/docs/5.8/database-testing
+ It can be said that it does not recreate after each test

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question