How to delete data from table after you perform the test?

0 like 0 dislike
7 views
As for phpunit, you can clear the table in test database after each test?
Tried to use: Illuminate\\Foundation\\Testing\efreshDatabase (lotion to testing in laravel), but this trait clears the database after performing all tests, i.e. it turns out that the performance of each test in the tables are data from other tests.
Could this have something to do or test data you want to remove yourself?
by | 7 views

1 Answer

0 like 0 dislike
In TestCase.php use
public function setUp() { parent::setUp(); \\Artisan::call('migrate:refresh'); \\Artisan::call('db:seed', ['--class' => 'TestDatabaseSeeder', '--database' => 'testing']); }

Then before each test the database will be returned to the original value.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,911 users