image(100, 100)->storeAs('uploads/public/c/pages', 'test.jpg', 'local'); Event::fire('media.file.delete', [null, '/pages/test.jpg', null]); $this->assertFileCount(0, 'pages'); Storage::assertMissing('uploads/public/c/pages'); } public function testItPreservesDirectoryWhenThereAreOtherFiles() { Setting::set('folders', ['pages']); Setting::set('sizes', []); Setting::set('breakpoints', []); UploadedFile::fake()->image(100, 100)->storeAs('uploads/public/c/pages', 'test.jpg', 'local'); UploadedFile::fake()->image(100, 100)->storeAs('uploads/public/c/pages', 'test2.jpg', 'local'); Event::fire('media.file.delete', [null, '/pages/test.jpg', null]); $this->assertHasFile('pages/test2.jpg'); $this->assertDoesntHaveFile('pages/test.jpg'); } public function testItDeletesFileVersions() { Setting::set('folders', ['pages']); Setting::set('sizes', []); Setting::set('breakpoints', []); UploadedFile::fake()->image(100, 100)->storeAs('uploads/public/c/pages', 'test.jpg', 'local'); UploadedFile::fake()->image(300, 500)->storeAs('uploads/public/c/pages', 'test-300x500.jpg', 'local'); Event::fire('media.file.delete', [null, '/pages/test.jpg', null]); $this->assertDoesntHaveFile('pages/test-300x500.jpg'); } }