Skip to content

A free open source IT asset/license management system

Implement test for assets

Marcus Moore16aa47509b3f
diff --git a/tests/Feature/Users/Ui/BulkDeleteUsersTest.php b/tests/Feature/Users/Ui/BulkDeleteUsersTest.php
index 4048f50b4c..8787e849e8 100644
--- a/tests/Feature/Users/Ui/BulkDeleteUsersTest.php
+++ b/tests/Feature/Users/Ui/BulkDeleteUsersTest.php
@@ -101,10 +101,34 @@ class BulkDeleteUsersTest extends TestCase
public function testAssetsCanBeBulkCheckedIn()
{
- $this->markTestIncomplete();
+ // $this->markTestIncomplete();
- // @todo:
- // $this->assertActionLogCheckInEntryFor(); ...
+ [$userA, $userB, $userC] = User::factory()->count(3)->create();
+
+ $assetA = $this->assignAssetToUser($userA);
+ $assetB = $this->assignAssetToUser($userB);
+ $assetC = $this->assignAssetToUser($userC);
+
+ $this->assertTrue($userA->assets->isNotEmpty());
+ $this->assertTrue($userB->assets->isNotEmpty());
+ $this->assertTrue($userC->assets->isNotEmpty());
+
+ $this->actingAs(User::factory()->editUsers()->create())
+ ->post(route('users/bulksave'), [
+ 'ids' => [
+ $userA->id,
+ $userC->id,
+ ],
+ 'status_id' => Statuslabel::factory()->create()->id,
+ ])
+ ->assertRedirect(route('users.index'));
+
+ $this->assertTrue($userA->fresh()->assets->isEmpty());
+ $this->assertTrue($userB->fresh()->assets->isNotEmpty());
+ $this->assertTrue($userC->fresh()->assets->isEmpty());
+
+ $this->assertActionLogCheckInEntryFor($userA, $assetA);
+ $this->assertActionLogCheckInEntryFor($userC, $assetC);
}
public function testConsumablesCanBeBulkCheckedIn()
@@ -200,4 +224,9 @@ class BulkDeleteUsersTest extends TestCase
'item_id' => $model->id,
]);
}
+
+ private function assignAssetToUser(User $user): Asset
+ {
+ return Asset::factory()->assignedToUser($user)->create();
+ }
}