mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
Add tests for license checkout notes
This commit is contained in:
parent
a08e0bd547
commit
4d2790c3f4
65
tests/Feature/Checkouts/LicenseCheckoutTest.php
Normal file
65
tests/Feature/Checkouts/LicenseCheckoutTest.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Checkouts;
|
||||||
|
|
||||||
|
use App\Models\Actionlog;
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\License;
|
||||||
|
use App\Models\LicenseSeat;
|
||||||
|
use App\Models\User;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class LicenseCheckoutTest extends TestCase
|
||||||
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
|
public function testNotesAreStoredInActionLogOnCheckoutToAsset()
|
||||||
|
{
|
||||||
|
$admin = User::factory()->superuser()->create();
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
$licenseSeat = LicenseSeat::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($admin)
|
||||||
|
->post("/licenses/{$licenseSeat->license->id}/checkout", [
|
||||||
|
'checkout_to_type' => 'asset',
|
||||||
|
'assigned_to' => null,
|
||||||
|
'asset_id' => $asset->id,
|
||||||
|
'notes' => 'oh hi there',
|
||||||
|
])
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('action_logs', [
|
||||||
|
'action_type' => 'checkout',
|
||||||
|
'target_id' => $asset->id,
|
||||||
|
'target_type' => Asset::class,
|
||||||
|
'item_id' => $licenseSeat->license->id,
|
||||||
|
'item_type' => License::class,
|
||||||
|
'note' => 'oh hi there',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNotesAreStoredInActionLogOnCheckoutToUser()
|
||||||
|
{
|
||||||
|
$admin = User::factory()->superuser()->create();
|
||||||
|
$licenseSeat = LicenseSeat::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($admin)
|
||||||
|
->post("/licenses/{$licenseSeat->license->id}/checkout", [
|
||||||
|
'checkout_to_type' => 'user',
|
||||||
|
'assigned_to' => $admin->id,
|
||||||
|
'asset_id' => null,
|
||||||
|
'notes' => 'oh hi there',
|
||||||
|
])
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('action_logs', [
|
||||||
|
'action_type' => 'checkout',
|
||||||
|
'target_id' => $admin->id,
|
||||||
|
'target_type' => User::class,
|
||||||
|
'item_id' => $licenseSeat->license->id,
|
||||||
|
'item_type' => License::class,
|
||||||
|
'note' => 'oh hi there',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue