3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 20:05:31 +00:00
Files
snipe-it/tests/Unit/Models/LicenseTest.php
2025-12-16 14:55:00 -08:00

54 lines
1.4 KiB
PHP

<?php
namespace Tests\Unit\Models;
use App\Enums\ActionType;
use App\Models\License;
use App\Models\User;
use Tests\TestCase;
class LicenseTest extends TestCase
{
public function test_adding_seats_is_logged_when_updating()
{
$user = User::factory()->create();
$this->actingAs($user);
$license = License::factory()->create(['seats' => 2]);
$license->update(['seats' => 6]);
$this->assertDatabaseHas('action_logs', [
'created_by' => $user->id,
'action_type' => ActionType::AddSeats,
'item_type' => License::class,
'item_id' => $license->id,
'deleted_at' => null,
// relevant for this test:
'quantity' => 4,
'note' => 'added 4 seats',
]);
}
public function test_removing_seats_is_logged_when_updating()
{
$user = User::factory()->create();
$this->actingAs($user);
$license = License::factory()->create(['seats' => 6]);
$license->update(['seats' => 3]);
$this->assertDatabaseHas('action_logs', [
'created_by' => $user->id,
'action_type' => ActionType::DeleteSeats,
'item_type' => License::class,
'item_id' => $license->id,
'deleted_at' => null,
// relevant for this test:
'quantity' => 3,
'note' => 'deleted 3 seats',
]);
}
}