我有一个用于测试上传功能的课程:
class FileUploadTest extends TestCase
{
protected $currentDate;
protected $filename;
public function setUp() {
parent::setUp();
$this->currentDate = now()->toDateString();
$this->filename = str_random(20) . '.jpg';
Storage::fake('uploads');
}
/** @test */
public function test_a_user_can_upload_a_file() {
$res = $this->json('POST', '/files', [
'file' => UploadedFile::fake()->image($this->filename)
]);
$content = $res->decodeResponseJson();
Storage::assertExists($content['path']);
}
...
}
$content['path']
有这种格式:'uploads/2018-06-06/filename.ext'
我看到每次测试后,都会在storage/app
文件夹中创建假文件。我该如何阻止它?