2023-08-21 12:31:51 -07:00
|
|
|
<?php
|
|
|
|
|
2024-02-12 17:54:22 -08:00
|
|
|
namespace Tests\Feature\Checkins;
|
2023-08-21 12:31:51 -07:00
|
|
|
|
|
|
|
use App\Models\Asset;
|
|
|
|
use App\Models\User;
|
|
|
|
use Tests\Support\InteractsWithSettings;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class AssetCheckinTest extends TestCase
|
|
|
|
{
|
|
|
|
use InteractsWithSettings;
|
|
|
|
|
2024-02-12 17:54:22 -08:00
|
|
|
public function testCheckingInAssetRequiresCorrectPermission()
|
|
|
|
{
|
|
|
|
$this->actingAs(User::factory()->create())
|
|
|
|
->post(route('hardware.checkin.store', [
|
|
|
|
'assetId' => Asset::factory()->assignedToUser()->create()->id,
|
|
|
|
]))
|
|
|
|
->assertForbidden();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAssetCanBeCheckedIn()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCheckInEmailSentToUserIfSettingEnabled()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCheckInEmailNotSentToUserIfSettingDisabled()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
2023-08-21 12:31:51 -07:00
|
|
|
public function testLastCheckInFieldIsSetOnCheckin()
|
|
|
|
{
|
|
|
|
$admin = User::factory()->superuser()->create();
|
|
|
|
$asset = Asset::factory()->create(['last_checkin' => null]);
|
|
|
|
|
|
|
|
$asset->checkOut(User::factory()->create(), $admin, now());
|
|
|
|
|
|
|
|
$this->actingAs($admin)
|
|
|
|
->post(route('hardware.checkin.store', [
|
|
|
|
'assetId' => $asset->id,
|
|
|
|
]))
|
|
|
|
->assertRedirect();
|
|
|
|
|
|
|
|
$this->assertNotNull(
|
|
|
|
$asset->fresh()->last_checkin,
|
|
|
|
'last_checkin field should be set on checkin'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|