Skip to content

A free open source IT asset/license management system

Consolidate test cases

Marcus Moore905df5ec2588
diff --git a/tests/Feature/Api/Assets/AssetCheckinTest.php b/tests/Feature/Api/Assets/AssetCheckinTest.php
index 83bbdab084..947828f550 100644
--- a/tests/Feature/Api/Assets/AssetCheckinTest.php
+++ b/tests/Feature/Api/Assets/AssetCheckinTest.php
@@ -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');
diff --git a/tests/Feature/Checkins/AssetCheckinTest.php b/tests/Feature/Checkins/AssetCheckinTest.php
index 925078ddfb..ad4d9074b7 100644
--- a/tests/Feature/Checkins/AssetCheckinTest.php
+++ b/tests/Feature/Checkins/AssetCheckinTest.php
@@ -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();