Skip to content

A free open source IT asset/license management system

merged develop, fix conflicts

Godfrey M0d28165c0449
diff --git a/tests/Feature/Checkins/Api/LicenseCheckinTest.php b/tests/Feature/Checkins/Api/LicenseCheckinTest.php
index e649b9f43b..385933655c 100644
--- a/tests/Feature/Checkins/Api/LicenseCheckinTest.php
+++ b/tests/Feature/Checkins/Api/LicenseCheckinTest.php
@@ -1,27 +1,45 @@
<?php
namespace Tests\Feature\Checkins\Api;
+use App\Models\License;
use App\Models\LicenseSeat;
use App\Models\User;
use Tests\TestCase;
-class LicenseCheckinTest extends TestCase
-{
-
- public function testUnreassignableLicenseSeatMarkedUponCheckin()
+class LicenseCheckInTest extends TestCase {
+ public function testLicenseCheckin()
{
- $licenseSeat = LicenseSeat::factory()
- ->notReassignable()
- ->assignedToUser()
- ->create();
+ $authUser = User::factory()->superuser()->create();
+ $this->actingAsForApi($authUser);
+
+ $license = License::factory()->create();
+ $oldUser = User::factory()->create();
+
+ $licenseSeat = LicenseSeat::factory()->for($license)->create([
+ 'assigned_to' => $oldUser->id,
+ 'notes' => 'Previously checked out',
+ ]);
- $this->assertEquals(false, $licenseSeat->unreassignable_seat);
+ $payload = [
+ 'assigned_to' => null,
+ 'asset_id' => null,
+ 'notes' => 'Checking in the seat',
+ ];
- $this->actingAs(User::factory()->checkoutLicenses()->create())
- ->post(route('licenses.checkin.save', $licenseSeat));
+ $response = $this->patchJson(
+ route('api.licenses.seats.update', [$license->id, $licenseSeat->id]),
+ $payload);
+
+ $response->assertStatus(200)
+ ->assertJsonFragment([
+ 'status' => 'success',
+ ]);
$licenseSeat->refresh();
- $this->assertEquals(true, $licenseSeat->unreassignable_seat);
+ $this->assertNull($licenseSeat->assigned_to);
+ $this->assertNull($licenseSeat->asset_id);
+
+ $this->assertEquals('Checking in the seat', $licenseSeat->notes);
}
}
\ No newline at end of file