Skip to content

A free open source IT asset/license management system

Add some assertions

Marcus Moore31a75bd252cc
diff --git a/database/factories/AssetFactory.php b/database/factories/AssetFactory.php
index 3fa0ae1d40..e6108ce943 100644
--- a/database/factories/AssetFactory.php
+++ b/database/factories/AssetFactory.php
@@ -295,6 +295,7 @@ class AssetFactory extends Factory
return [
'assigned_to' => $user->id ?? User::factory(),
'assigned_type' => User::class,
+ 'last_checkout' => now()->subDay(),
];
});
}
diff --git a/tests/Feature/Checkins/AssetCheckinTest.php b/tests/Feature/Checkins/AssetCheckinTest.php
index 95cf639f82..6b0fdd0e7a 100644
--- a/tests/Feature/Checkins/AssetCheckinTest.php
+++ b/tests/Feature/Checkins/AssetCheckinTest.php
@@ -4,6 +4,7 @@ namespace Tests\Feature\Checkins;
use App\Events\CheckoutableCheckedIn;
use App\Models\Asset;
+use App\Models\Statuslabel;
use App\Models\User;
use App\Notifications\CheckinAssetNotification;
use Illuminate\Support\Facades\Event;
@@ -34,32 +35,51 @@ class AssetCheckinTest extends TestCase
$this->markTestIncomplete();
}
- public function testAssetCheckedOutToAssetCanBeCheckedIn()
- {
- $this->markTestIncomplete();
- }
-
- public function testAssetCheckedOutToLocationCanBeCheckedIn()
- {
- $this->markTestIncomplete();
- }
-
public function testAssetCheckedOutToUserCanBeCheckedIn()
{
Event::fake([CheckoutableCheckedIn::class]);
$admin = User::factory()->checkinAssets()->create();
$user = User::factory()->create();
- $asset = Asset::factory()->assignedToUser($user)->create();
+ $status = Statuslabel::first() ?? Statuslabel::factory()->create();
+ $asset = Asset::factory()->assignedToUser($user)->create([
+ 'expected_checkin' => now()->addDay(),
+ 'last_checkin' => null,
+ 'accepted' => 'accepted',
+ ]);
$this->assertTrue($asset->assignedTo->is($user));
$this->actingAs($admin)
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id, 'backto' => 'user']))
+ ->post(
+ route('hardware.checkin.store', ['assetId' => $asset->id, 'backto' => 'user']),
+ [
+ 'name' => 'Changed Name',
+ 'status_id' => $status->id,
+ ],
+ )
->assertRedirect(route('users.show', $user));
- $this->assertNull($asset->fresh()->assignedTo);
Event::assertDispatched(CheckoutableCheckedIn::class, 1);
+ $this->assertNull($asset->refresh()->assignedTo);
+ $this->assertNull($asset->expected_checkin);
+ $this->assertNull($asset->last_checkout);
+ $this->assertNotNull($asset->last_checkin);
+ $this->assertNull($asset->assignedTo);
+ $this->assertNull($asset->assigned_type);
+ $this->assertNull($asset->accepted);
+ $this->assertEquals('Changed Name', $asset->name);
+ $this->assertEquals($status->id, $asset->status_id);
+ }
+
+ public function testAssetCheckedOutToAssetCanBeCheckedIn()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testAssetCheckedOutToLocationCanBeCheckedIn()
+ {
+ $this->markTestIncomplete();
}
public function testLastCheckInFieldIsSetOnCheckin()