Consolidate test cases

This commit is contained in:
Marcus Moore 2024-02-14 12:14:27 -08:00
parent bacfdc5049
commit 905df5ec25
No known key found for this signature in database
2 changed files with 6 additions and 26 deletions

View file

@ -42,6 +42,7 @@ class AssetCheckinTest extends TestCase
Event::fake([CheckoutableCheckedIn::class]);
$user = User::factory()->create();
$location = Location::factory()->create();
$status = Statuslabel::factory()->create();
$asset = Asset::factory()->assignedToUser($user)->create([
'expected_checkin' => now()->addDay(),
@ -55,6 +56,7 @@ class AssetCheckinTest extends TestCase
->postJson(route('api.asset.checkin', $asset), [
'name' => 'Changed Name',
'status_id' => $status->id,
'location_id' => $location->id,
])
->assertOk();
@ -68,6 +70,7 @@ class AssetCheckinTest extends TestCase
$this->assertNull($asset->accepted);
$this->assertEquals('Changed Name', $asset->name);
$this->assertEquals($status->id, $asset->status_id);
$this->assertTrue($asset->location()->is($location));
}
public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
@ -84,19 +87,6 @@ class AssetCheckinTest extends TestCase
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
}
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('Not currently in controller');

View file

@ -39,6 +39,7 @@ class AssetCheckinTest extends TestCase
Event::fake([CheckoutableCheckedIn::class]);
$user = User::factory()->create();
$location = Location::factory()->create();
$status = Statuslabel::first() ?? Statuslabel::factory()->create();
$asset = Asset::factory()->assignedToUser($user)->create([
'expected_checkin' => now()->addDay(),
@ -54,6 +55,7 @@ class AssetCheckinTest extends TestCase
[
'name' => 'Changed Name',
'status_id' => $status->id,
'location_id' => $location->id,
],
)
->assertRedirect(route('users.show', $user));
@ -68,6 +70,7 @@ class AssetCheckinTest extends TestCase
$this->assertNull($asset->accepted);
$this->assertEquals('Changed Name', $asset->name);
$this->assertEquals($status->id, $asset->status_id);
$this->assertTrue($asset->location()->is($location));
}
public function testLocationIsSetToRTDLocationByDefaultUponCheckin()
@ -84,19 +87,6 @@ class AssetCheckinTest extends TestCase
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
}
public function testLocationCanBeSetUponCheckin()
{
$location = Location::factory()->create();
$asset = Asset::factory()->assignedToUser()->create();
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route('hardware.checkin.store', ['assetId' => $asset->id]), [
'location_id' => $location->id,
]);
$this->assertTrue($asset->refresh()->location()->is($location));
}
public function testDefaultLocationCanBeUpdatedUponCheckin()
{
$location = Location::factory()->create();