Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```File: tests/TestCase.php```
- ```php
- use Illuminate\Support\Facades\DB;
- public function tearDown()
- {
- $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'YOUR_DATABASE_NAME';";
- DB::statement("SET FOREIGN_KEY_CHECKS = 0;");
- $tables = DB::select($sql);
- array_walk($tables, function($table){
- if ($table->TABLE_NAME != 'migrations') {
- DB::table($table->TABLE_NAME)->truncate();
- }
- });
- DB::statement("SET FOREIGN_KEY_CHECKS = 1;");
- parent::tearDown();
- }
- ```
Add Comment
Please, Sign In to add comment