mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Improve readability
This commit is contained in:
parent
78a0417ee9
commit
480e4f3a69
|
@ -16,12 +16,8 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
[$userA, $userB, $userC] = User::factory()->count(3)->create();
|
[$userA, $userB, $userC] = User::factory()->count(3)->create();
|
||||||
|
|
||||||
// Add checkouts for multiple accessories to multiple users to get different ids in the mix
|
// Add checkouts for multiple accessories to multiple users to get different ids in the mix
|
||||||
$this->attachAccessoryToUser($accessoryA, $userA);
|
$this->attachAccessoryToUsers($accessoryA, [$userA, $userB, $userC]);
|
||||||
$this->attachAccessoryToUser($accessoryA, $userB);
|
$this->attachAccessoryToUsers($accessoryB, [$userA, $userB]);
|
||||||
$this->attachAccessoryToUser($accessoryA, $userC);
|
|
||||||
|
|
||||||
$this->attachAccessoryToUser($accessoryB, $userA);
|
|
||||||
$this->attachAccessoryToUser($accessoryB, $userB);
|
|
||||||
|
|
||||||
$this->actingAs(User::factory()->editUsers()->create())
|
$this->actingAs(User::factory()->editUsers()->create())
|
||||||
->post(route('users/bulksave'), [
|
->post(route('users/bulksave'), [
|
||||||
|
@ -69,12 +65,8 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
[$userA, $userB, $userC] = User::factory()->count(3)->create();
|
[$userA, $userB, $userC] = User::factory()->count(3)->create();
|
||||||
|
|
||||||
// Add checkouts for multiple consumables to multiple users to get different ids in the mix
|
// Add checkouts for multiple consumables to multiple users to get different ids in the mix
|
||||||
$this->attachConsumableToUser($consumableA, $userA);
|
$this->attachConsumableToUsers($consumableA, [$userA, $userB, $userC]);
|
||||||
$this->attachConsumableToUser($consumableA, $userB);
|
$this->attachConsumableToUsers($consumableB, [$userA, $userB]);
|
||||||
$this->attachConsumableToUser($consumableA, $userC);
|
|
||||||
|
|
||||||
$this->attachConsumableToUser($consumableB, $userA);
|
|
||||||
$this->attachConsumableToUser($consumableB, $userB);
|
|
||||||
|
|
||||||
$this->actingAs(User::factory()->editUsers()->create())
|
$this->actingAs(User::factory()->editUsers()->create())
|
||||||
->post(route('users/bulksave'), [
|
->post(route('users/bulksave'), [
|
||||||
|
@ -116,19 +108,23 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function attachAccessoryToUser(Accessory $accessory, User $user): void
|
private function attachAccessoryToUsers(Accessory $accessory, array $users): void
|
||||||
{
|
{
|
||||||
$accessory->users()->attach($accessory->id, [
|
foreach ($users as $user) {
|
||||||
'accessory_id' => $accessory->id,
|
$accessory->users()->attach($accessory->id, [
|
||||||
'assigned_to' => $user->id,
|
'accessory_id' => $accessory->id,
|
||||||
]);
|
'assigned_to' => $user->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function attachConsumableToUser(Consumable $consumable, User $user): void
|
private function attachConsumableToUsers(Consumable $consumable, array $users): void
|
||||||
{
|
{
|
||||||
$consumable->users()->attach($consumable->id, [
|
foreach ($users as $user) {
|
||||||
'consumable_id' => $consumable->id,
|
$consumable->users()->attach($consumable->id, [
|
||||||
'assigned_to' => $user->id,
|
'consumable_id' => $consumable->id,
|
||||||
]);
|
'assigned_to' => $user->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue