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
27 lines
621 B
<?php
|
|
|
|
namespace Tests\Base;
|
|
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
trait FreshMongodbDatabase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->clearAllCollections();
|
|
}
|
|
|
|
public function clearAllCollections() {
|
|
$path = app_path('Documents');
|
|
$files = File::allFiles($path);
|
|
|
|
foreach ($files as $file) {
|
|
$className = str_replace('.php', '', $file->getFileName());
|
|
if ($className === 'BaseDocument'){
|
|
continue;
|
|
}
|
|
call_user_func('App\\Documents\\' . $className . "::truncate");
|
|
}
|
|
}
|
|
}
|