You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
621 B

2 years ago
  1. <?php
  2. namespace Tests\Base;
  3. use Illuminate\Support\Facades\File;
  4. trait FreshMongodbDatabase
  5. {
  6. public function setUp(): void
  7. {
  8. parent::setUp();
  9. $this->clearAllCollections();
  10. }
  11. public function clearAllCollections() {
  12. $path = app_path('Documents');
  13. $files = File::allFiles($path);
  14. foreach ($files as $file) {
  15. $className = str_replace('.php', '', $file->getFileName());
  16. if ($className === 'BaseDocument'){
  17. continue;
  18. }
  19. call_user_func('App\\Documents\\' . $className . "::truncate");
  20. }
  21. }
  22. }