mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Improve readability
This commit is contained in:
parent
bfebcdc7ed
commit
364775dcfe
|
@ -6,6 +6,7 @@ use App\Models\Accessory;
|
||||||
use App\Models\Consumable;
|
use App\Models\Consumable;
|
||||||
use App\Models\Statuslabel;
|
use App\Models\Statuslabel;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class BulkDeleteUsersTest extends TestCase
|
class BulkDeleteUsersTest extends TestCase
|
||||||
|
@ -31,32 +32,9 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
|
|
||||||
// These assertions check against a bug where the wrong value from
|
// These assertions check against a bug where the wrong value from
|
||||||
// accessories_users was being populated in action_logs.item_id.
|
// accessories_users was being populated in action_logs.item_id.
|
||||||
$this->assertDatabaseHas('action_logs', [
|
$this->assertActionLogCheckInEntryFor($userA, $accessoryA);
|
||||||
'action_type' => 'checkin from',
|
$this->assertActionLogCheckInEntryFor($userA, $accessoryB);
|
||||||
'target_id' => $userA->id,
|
$this->assertActionLogCheckInEntryFor($userC, $accessoryA);
|
||||||
'target_type' => User::class,
|
|
||||||
'note' => 'Bulk checkin items',
|
|
||||||
'item_type' => Accessory::class,
|
|
||||||
'item_id' => $accessoryA->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('action_logs', [
|
|
||||||
'action_type' => 'checkin from',
|
|
||||||
'target_id' => $userA->id,
|
|
||||||
'target_type' => User::class,
|
|
||||||
'note' => 'Bulk checkin items',
|
|
||||||
'item_type' => Accessory::class,
|
|
||||||
'item_id' => $accessoryB->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('action_logs', [
|
|
||||||
'action_type' => 'checkin from',
|
|
||||||
'target_id' => $userC->id,
|
|
||||||
'target_type' => User::class,
|
|
||||||
'note' => 'Bulk checkin items',
|
|
||||||
'item_type' => Accessory::class,
|
|
||||||
'item_id' => $accessoryA->id,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConsumableCheckinsAreProperlyLogged()
|
public function testConsumableCheckinsAreProperlyLogged()
|
||||||
|
@ -80,32 +58,9 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
|
|
||||||
// These assertions check against a bug where the wrong value from
|
// These assertions check against a bug where the wrong value from
|
||||||
// consumables_users was being populated in action_logs.item_id.
|
// consumables_users was being populated in action_logs.item_id.
|
||||||
$this->assertDatabaseHas('action_logs', [
|
$this->assertActionLogCheckInEntryFor($userA, $consumableA);
|
||||||
'action_type' => 'checkin from',
|
$this->assertActionLogCheckInEntryFor($userA, $consumableB);
|
||||||
'target_id' => $userA->id,
|
$this->assertActionLogCheckInEntryFor($userC, $consumableA);
|
||||||
'target_type' => User::class,
|
|
||||||
'note' => 'Bulk checkin items',
|
|
||||||
'item_type' => Consumable::class,
|
|
||||||
'item_id' => $consumableA->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('action_logs', [
|
|
||||||
'action_type' => 'checkin from',
|
|
||||||
'target_id' => $userA->id,
|
|
||||||
'target_type' => User::class,
|
|
||||||
'note' => 'Bulk checkin items',
|
|
||||||
'item_type' => Consumable::class,
|
|
||||||
'item_id' => $consumableB->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertDatabaseHas('action_logs', [
|
|
||||||
'action_type' => 'checkin from',
|
|
||||||
'target_id' => $userC->id,
|
|
||||||
'target_type' => User::class,
|
|
||||||
'note' => 'Bulk checkin items',
|
|
||||||
'item_type' => Consumable::class,
|
|
||||||
'item_id' => $consumableA->id,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function attachAccessoryToUsers(Accessory $accessory, array $users): void
|
private function attachAccessoryToUsers(Accessory $accessory, array $users): void
|
||||||
|
@ -127,4 +82,16 @@ class BulkDeleteUsersTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function assertActionLogCheckInEntryFor(User $user, Model $model): void
|
||||||
|
{
|
||||||
|
$this->assertDatabaseHas('action_logs', [
|
||||||
|
'action_type' => 'checkin from',
|
||||||
|
'target_id' => $user->id,
|
||||||
|
'target_type' => User::class,
|
||||||
|
'note' => 'Bulk checkin items',
|
||||||
|
'item_type' => get_class($model),
|
||||||
|
'item_id' => $model->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue