Implement test for assets
This commit is contained in:
parent
d1bb3ef6bf
commit
16aa47509b
1 changed files with 32 additions and 3 deletions
|
@ -101,10 +101,34 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
|
|
||||||
public function testAssetsCanBeBulkCheckedIn()
|
public function testAssetsCanBeBulkCheckedIn()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
// $this->markTestIncomplete();
|
||||||
|
|
||||||
// @todo:
|
[$userA, $userB, $userC] = User::factory()->count(3)->create();
|
||||||
// $this->assertActionLogCheckInEntryFor(); ...
|
|
||||||
|
$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()
|
public function testConsumablesCanBeBulkCheckedIn()
|
||||||
|
@ -200,4 +224,9 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
'item_id' => $model->id,
|
'item_id' => $model->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function assignAssetToUser(User $user): Asset
|
||||||
|
{
|
||||||
|
return Asset::factory()->assignedToUser($user)->create();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue