A free open source IT asset/license management system
add checkout test for api
Godfrey M66fd46fe75b2
diff --git a/tests/Feature/Checkouts/Api/LicenseCheckOutTest.php b/tests/Feature/Checkouts/Api/LicenseCheckOutTest.phpnew file mode 100644index 0000000000..70364ca428--- /dev/null+++ b/tests/Feature/Checkouts/Api/LicenseCheckOutTest.php@@ -0,0 +1,41 @@+<?php+namespace Feature\Checkouts\Api;++use App\Models\License;+use App\Models\LicenseSeat;+use App\Models\User;+use Tests\TestCase;++class LicenseCheckOutTest extends TestCase {+ public function testLicenseCheckout()+ {+ $authUser = User::factory()->superuser()->make();+ $this->actingAsForApi($authUser);++ $license = License::factory()->create();+ $licenseSeat = LicenseSeat::factory()->for($license)->create([+ 'assigned_to' => null,+ ]);++ $targetUser = User::factory()->create();++ $payload = [+ 'assigned_to' => $targetUser->id,+ 'notes' => 'Checking out the seat to a user',+ ];++ $response = $this->patchJson(+ route('api.licenses.seats.update', [$license->id, $licenseSeat->id]),+ $payload);++ $response->assertStatus(200)+ ->assertJsonFragment([+ 'status' => 'success',+ ]);++ $licenseSeat->refresh();++ $this->assertEquals($targetUser->id, $licenseSeat->assigned_to);+ $this->assertEquals('Checking out the seat to a user', $licenseSeat->notes);+ }+}\ No newline at end of file