From e028145ad91d6731e528663b02c2eb3d87b07c75 Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 13 Dec 2023 09:16:08 -0600 Subject: [PATCH] Add new asset tests for archive, depreciate, and physical fields --- tests/Feature/Api/Assets/AssetStoreTest.php | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/Feature/Api/Assets/AssetStoreTest.php b/tests/Feature/Api/Assets/AssetStoreTest.php index 922c3a89e0..720526f5b5 100644 --- a/tests/Feature/Api/Assets/AssetStoreTest.php +++ b/tests/Feature/Api/Assets/AssetStoreTest.php @@ -85,6 +85,56 @@ class AssetStoreTest extends TestCase $this->assertEquals(10, $asset->warranty_months); } + public function testArchivedDepreciateAndPhysicalCanBeNull() + { + $model = AssetModel::factory()->ipadModel()->create(); + $status = Statuslabel::factory()->create(); + + $this->settings->enableAutoIncrement(); + + $response = $this->actingAsForApi(User::factory()->superuser()->create()) + ->postJson(route('api.assets.store'), [ + 'model_id' => $model->id, + 'status_id' => $status->id, + 'archive' => null, + 'depreciate' => null, + 'physical' => null + ]) + ->assertOk() + ->assertStatusMessageIs('success') + ->json(); + + $asset = Asset::find($response['payload']['id']); + $this->assertEquals(0, $asset->archived); + $this->assertEquals(1, $asset->physical); + $this->assertEquals(0, $asset->depreciate); + } + + public function testArchivedDepreciateAndPhysicalCanBeEmpty() + { + $model = AssetModel::factory()->ipadModel()->create(); + $status = Statuslabel::factory()->create(); + + $this->settings->enableAutoIncrement(); + + $response = $this->actingAsForApi(User::factory()->superuser()->create()) + ->postJson(route('api.assets.store'), [ + 'model_id' => $model->id, + 'status_id' => $status->id, + 'archive' => '', + 'depreciate' => '', + 'physical' => '' + ]) + ->assertOk() + ->assertStatusMessageIs('success') + ->json(); + + $asset = Asset::find($response['payload']['id']); + $this->assertEquals(0, $asset->archived); + $this->assertEquals(1, $asset->physical); + $this->assertEquals(0, $asset->depreciate); + } + public function testAssetEolDateIsCalculatedIfPurchaseDateSet() { $model = AssetModel::factory()->mbp13Model()->create();