Scaffold tests

This commit is contained in:
Marcus Moore 2024-02-14 11:11:08 -08:00
parent 02f39472f9
commit 4354e126b1
No known key found for this signature in database

View file

@ -4,6 +4,7 @@ namespace Tests\Feature\Api\Assets;
use App\Events\CheckoutableCheckedIn; use App\Events\CheckoutableCheckedIn;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Location;
use App\Models\Statuslabel; use App\Models\Statuslabel;
use App\Models\User; use App\Models\User;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
@ -50,7 +51,7 @@ class AssetCheckinTest extends TestCase
$this->assertTrue($asset->assignedTo->is($user)); $this->assertTrue($asset->assignedTo->is($user));
$this->actingAsForApi(User::factory()->checkinAssets()->create()) $this->actingAsForApi(User::factory()->checkinAssets()->create())
->postJson(route('api.asset.checkin', $asset->id), [ ->postJson(route('api.asset.checkin', $asset), [
'name' => 'Changed Name', 'name' => 'Changed Name',
'status_id' => $status->id, 'status_id' => $status->id,
]) ])
@ -68,22 +69,54 @@ class AssetCheckinTest extends TestCase
$this->assertEquals($status->id, $asset->status_id); $this->assertEquals($status->id, $asset->status_id);
} }
public function testLastCheckInFieldIsSetOnCheckin() public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
{ {
$admin = User::factory()->checkinAssets()->create(); $rtdLocation = Location::factory()->create();
$asset = Asset::factory()->assignedToUser()->create(['last_checkin' => null]); $asset = Asset::factory()->assignedToUser()->create([
'location_id' => Location::factory()->create()->id,
'rtd_location_id' => $rtdLocation->id,
]);
$this->actingAsForApi($admin) $this->actingAsForApi(User::factory()->checkinAssets()->create())
->postJson(route('api.asset.checkin', $asset)) ->postJson(route('api.asset.checkin', $asset->id));
->assertOk();
$this->assertNotNull( $this->assertTrue($asset->refresh()->location()->is($rtdLocation));
$asset->fresh()->last_checkin, }
'last_checkin field should be set on checkin'
); public function testLocationCanBeSetUponCheckin()
{
$location = Location::factory()->create();
$asset = Asset::factory()->assignedToUser()->create();
$this->actingAsForApi(User::factory()->checkinAssets()->create())
->postJson(route('api.asset.checkin', $asset->id), [
'location_id' => $location->id,
]);
$this->assertTrue($asset->refresh()->location()->is($location));
}
public function testDefaultLocationCanBeUpdatedUponCheckin()
{
$this->markTestIncomplete();
}
public function testAssetsLicenseSeatsAreClearedUponCheckin()
{
$this->markTestIncomplete();
}
public function testLegacyLocationValuesSetToZeroAreUpdated()
{
$this->markTestIncomplete();
} }
public function testPendingCheckoutAcceptancesAreClearedUponCheckin() public function testPendingCheckoutAcceptancesAreClearedUponCheckin()
{
$this->markTestIncomplete('Not currently in controller');
}
public function testCheckinTimeAndActionLogNoteCanBeSet()
{ {
$this->markTestIncomplete(); $this->markTestIncomplete();
} }