Guest User

Untitled

a guest
Jan 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. ```File: tests/TestCase.php```
  2.  
  3. ```php
  4.  
  5. use Illuminate\Support\Facades\DB;
  6.  
  7. public function tearDown()
  8. {
  9.  
  10. $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'YOUR_DATABASE_NAME';";
  11.  
  12. DB::statement("SET FOREIGN_KEY_CHECKS = 0;");
  13. $tables = DB::select($sql);
  14.  
  15. array_walk($tables, function($table){
  16. if ($table->TABLE_NAME != 'migrations') {
  17. DB::table($table->TABLE_NAME)->truncate();
  18. }
  19. });
  20.  
  21. DB::statement("SET FOREIGN_KEY_CHECKS = 1;");
  22. parent::tearDown();
  23. }
  24. ```
Add Comment
Please, Sign In to add comment