Implement test for assets

This commit is contained in:
Marcus Moore 2024-08-05 16:24:52 -07:00
parent d1bb3ef6bf
commit 16aa47509b
No known key found for this signature in database

View file

@ -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();
}
}