A free open source IT asset/license management system
Scaffold additional tests
Marcus Moorebacfdc504922
diff --git a/tests/Feature/Api/Assets/AssetCheckinTest.php b/tests/Feature/Api/Assets/AssetCheckinTest.phpindex 32aed3616e..83bbdab084 100644--- a/tests/Feature/Api/Assets/AssetCheckinTest.php+++ b/tests/Feature/Api/Assets/AssetCheckinTest.php@@ -4,6 +4,7 @@ namespace Tests\Feature\Api\Assets;use App\Events\CheckoutableCheckedIn;use App\Models\Asset;+use App\Models\LicenseSeat;use App\Models\Location;use App\Models\Statuslabel;use App\Models\User;@@ -98,17 +99,38 @@ class AssetCheckinTest extends TestCasepublic function testDefaultLocationCanBeUpdatedUponCheckin(){- $this->markTestIncomplete();+ $this->markTestIncomplete('Not currently in controller');++ $location = Location::factory()->create();+ $asset = Asset::factory()->assignedToUser()->create();++ $this->actingAsForApi(User::factory()->checkinAssets()->create())+ ->postJson(route('api.asset.checkin', $asset), [+ 'location_id' => $location->id,+ 'update_default_location' => 0+ ]);++ $this->assertTrue($asset->refresh()->defaultLoc()->is($location));}public function testAssetsLicenseSeatsAreClearedUponCheckin(){- $this->markTestIncomplete();+ $this->markTestIncomplete('Not currently in controller');++ $asset = Asset::factory()->assignedToUser()->create();+ LicenseSeat::factory()->assignedToUser()->for($asset)->create();++ $this->assertNotNull($asset->licenseseats->first()->assigned_to);++ $this->actingAsForApi(User::factory()->checkinAssets()->create())+ ->postJson(route('api.asset.checkin', $asset));++ $this->assertNull($asset->refresh()->licenseseats->first()->assigned_to);}public function testLegacyLocationValuesSetToZeroAreUpdated(){- $this->markTestIncomplete();+ $this->markTestIncomplete('Not currently in controller');}public function testPendingCheckoutAcceptancesAreClearedUponCheckin()@@ -118,6 +140,20 @@ class AssetCheckinTest extends TestCasepublic function testCheckinTimeAndActionLogNoteCanBeSet(){- $this->markTestIncomplete();+ $this->markTestIncomplete(+ 'checkin_at currently takes a date and applies a time which is not inline with what the web controller does.'+ );++ Event::fake();++ $this->actingAsForApi(User::factory()->checkinAssets()->create())+ ->postJson(route('api.asset.checkin', Asset::factory()->assignedToUser()->create()), [+ 'checkin_at' => '2023-01-02 12:34:56',+ 'note' => 'hi there',+ ]);++ Event::assertDispatched(function (CheckoutableCheckedIn $event) {+ return $event->action_date === '2023-01-02 12:34:56' && $event->note === 'hi there';+ }, 1);}}diff --git a/tests/Feature/Checkins/AssetCheckinTest.php b/tests/Feature/Checkins/AssetCheckinTest.phpindex 5bd19175bf..925078ddfb 100644--- a/tests/Feature/Checkins/AssetCheckinTest.php+++ b/tests/Feature/Checkins/AssetCheckinTest.php@@ -159,12 +159,12 @@ class AssetCheckinTest extends TestCase'hardware.checkin.store',['assetId' => Asset::factory()->assignedToUser()->create()->id]), [- 'checkin_at' => '2023-01-02 12:45:56',+ 'checkin_at' => '2023-01-02 12:34:56','note' => 'hello']);Event::assertDispatched(function (CheckoutableCheckedIn $event) {- return $event->action_date === '2023-01-02 12:45:56' && $event->note === 'hello';+ return $event->action_date === '2023-01-02 12:34:56' && $event->note === 'hello';}, 1);}}