mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-24 04:03:34 -08:00
Implement test for assets
This commit is contained in:
parent
d1bb3ef6bf
commit
16aa47509b
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue