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


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
27 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 | 27 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,187 answers
0 comments
40,796 users