From 2acb0b3362cde0dc591c4071db1544fd1b43a7ba Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 21 Jul 2026 17:07:20 +0100 Subject: [PATCH] Fixed tests with new expectation that the image is NOT deleted on soft-delete --- tests/Feature/Assets/Ui/DeleteAssetTest.php | 9 +++++++-- tests/Feature/Components/Ui/DeleteComponentTest.php | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/Feature/Assets/Ui/DeleteAssetTest.php b/tests/Feature/Assets/Ui/DeleteAssetTest.php index a086c6238f..c2c606c6c0 100644 --- a/tests/Feature/Assets/Ui/DeleteAssetTest.php +++ b/tests/Feature/Assets/Ui/DeleteAssetTest.php @@ -99,8 +99,13 @@ class DeleteAssetTest extends TestCase Event::assertDispatched(CheckoutableCheckedIn::class); } - public function test_image_is_deleted_when_asset_deleted() + public function test_image_is_preserved_when_asset_soft_deleted() { + // Soft-deleting an asset preserves its image on disk so a + // restored asset still has one. The image is only removed for + // good by `snipeit:purge` when the row is force-deleted. + // Coverage for that permanent-removal path lives in + // `tests/Feature/Console/Commands/PurgeTest.php`. Storage::fake('public'); $asset = Asset::factory()->create(['image' => 'image.jpg']); @@ -112,6 +117,6 @@ class DeleteAssetTest extends TestCase $this->actingAs(User::factory()->deleteAssets()->create()) ->delete(route('hardware.destroy', $asset)); - Storage::disk('public')->assertMissing('assets/image.jpg'); + Storage::disk('public')->assertExists('assets/image.jpg'); } } diff --git a/tests/Feature/Components/Ui/DeleteComponentTest.php b/tests/Feature/Components/Ui/DeleteComponentTest.php index ece7b0d538..59c25510cc 100644 --- a/tests/Feature/Components/Ui/DeleteComponentTest.php +++ b/tests/Feature/Components/Ui/DeleteComponentTest.php @@ -50,8 +50,13 @@ class DeleteComponentTest extends TestCase implements TestsFullMultipleCompanies ->assertRedirect(route('components.index')); } - public function test_deleting_component_removes_component_image() + public function test_deleting_component_preserves_component_image() { + // Soft-deleting a component preserves its image on disk so a + // restored component still has one. The image is only removed + // for good by `snipeit:purge` when the row is force-deleted. + // Coverage for that permanent-removal path lives in + // `tests/Feature/Console/Commands/PurgeTest.php`. Storage::fake('public'); $component = Component::factory()->create(['image' => 'component-image.jpg']); @@ -62,7 +67,7 @@ class DeleteComponentTest extends TestCase implements TestsFullMultipleCompanies $this->actingAs(User::factory()->deleteComponents()->create())->delete(route('components.destroy', $component->id)); - Storage::disk('public')->assertMissing('components/component-image.jpg'); + Storage::disk('public')->assertExists('components/component-image.jpg'); } public function test_deleting_component_is_logged()