mirror of
https://github.com/snipe/snipe-it.git
synced 2026-08-18 11:15:42 +00:00
Fixed tests with new expectation that the image is NOT deleted on soft-delete
This commit is contained in:
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user