Skip to content

A free open source IT asset/license management system

Updated tests

snipe55cf5877c465
diff --git a/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php b/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php
index 747028e5e1..ec8ed33ba8 100644
--- a/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php
+++ b/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php
@@ -137,6 +137,10 @@ class BulkDeleteAssetsTest extends TestCase
'item_type' => Asset::class,
]
);
+
+ $asset->refresh();
+ $this->assertNull($asset->assigned_to);
+ $this->assertNull($asset->assigned_type);
}
public function testActionLogCreatedUponBulkRestore()
diff --git a/tests/Feature/Assets/Ui/DeleteAssetTest.php b/tests/Feature/Assets/Ui/DeleteAssetTest.php
index a12e9e2cd0..799643929b 100644
--- a/tests/Feature/Assets/Ui/DeleteAssetTest.php
+++ b/tests/Feature/Assets/Ui/DeleteAssetTest.php
@@ -48,6 +48,29 @@ class DeleteAssetTest extends TestCase
]);
}
+ public function testActionLogsActionDateIsPopulatedWhenAssetDeleted()
+ {
+ $actor = User::factory()->deleteAssets()->create();
+
+ $asset = Asset::factory()->create();
+
+ $this->actingAs($actor)->delete(route('hardware.destroy', $asset));
+
+ $asset->refresh();
+
+ $this->assertDatabaseHas('action_logs', [
+ 'action_date' => $asset->updated_at,
+ 'created_at' => $asset->updated_at,
+ 'created_by' => $actor->id,
+ 'action_type' => 'delete',
+ 'target_id' => null,
+ 'target_type' => null,
+ 'item_type' => Asset::class,
+ 'item_id' => $asset->id,
+ ]);
+
+ }
+
public function testAssetIsCheckedInWhenDeleted()
{
Event::fake();
@@ -65,6 +88,10 @@ class DeleteAssetTest extends TestCase
'Asset still assigned to user after deletion'
);
+ $asset->refresh();
+ $this->assertNull($asset->assigned_to);
+ $this->assertNull($asset->assigned_type);
+
Event::assertDispatched(CheckoutableCheckedIn::class);
}