snipe-it/tests/Feature/Api/Assets/AssetCheckinTest.php

70 lines
1.9 KiB
PHP
Raw Normal View History

2023-08-21 12:31:51 -07:00
<?php
namespace Tests\Feature\Api\Assets;
use App\Models\Asset;
use App\Models\User;
use Tests\Support\InteractsWithSettings;
use Tests\TestCase;
class AssetCheckinTest extends TestCase
{
use InteractsWithSettings;
2024-02-13 12:15:59 -08:00
public function testCheckingInAssetRequiresCorrectPermission()
{
2024-02-13 17:50:26 -08:00
$this->actingAsForApi(User::factory()->create())
->postJson(route('api.asset.checkin', Asset::factory()->assignedToUser()->create()))
->assertForbidden();
2024-02-13 12:15:59 -08:00
}
2024-02-13 12:35:31 -08:00
public function testCannotCheckInNonExistentAsset()
2024-02-13 12:15:59 -08:00
{
2024-02-13 17:50:26 -08:00
$this->actingAsForApi(User::factory()->checkinAssets()->create())
->postJson(route('api.asset.checkin', ['id' => 'does-not-exist']))
->assertStatusMessageIs('error');
2024-02-13 12:15:59 -08:00
}
2024-02-13 12:35:31 -08:00
public function testCannotCheckInAssetThatIsNotCheckedOut()
2024-02-13 12:15:59 -08:00
{
2024-02-13 17:50:26 -08:00
$this->actingAsForApi(User::factory()->checkinAssets()->create())
->postJson(route('api.asset.checkin', Asset::factory()->create()->id))
->assertStatusMessageIs('error');
2024-02-13 12:15:59 -08:00
}
2024-02-13 17:50:26 -08:00
public function testAssetCanBeCheckedIn()
2024-02-13 12:15:59 -08:00
{
$this->markTestIncomplete();
}
2023-08-21 12:31:51 -07:00
public function testLastCheckInFieldIsSetOnCheckin()
{
2024-02-13 17:50:26 -08:00
$admin = User::factory()->checkinAssets()->create();
$asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]);
2023-08-21 12:31:51 -07:00
$this->actingAsForApi($admin)
->postJson(route('api.asset.checkin', $asset))
->assertOk();
$this->assertNotNull(
$asset->fresh()->last_checkin,
'last_checkin field should be set on checkin'
);
}
2024-02-13 12:35:31 -08:00
public function testPendingCheckoutAcceptancesAreClearedUponCheckin()
{
$this->markTestIncomplete();
}
public function testCheckInEmailSentToUserIfSettingEnabled()
{
$this->markTestIncomplete();
}
public function testCheckInEmailNotSentToUserIfSettingDisabled()
{
$this->markTestIncomplete();
}
2023-08-21 12:31:51 -07:00
}