buncha progress
This commit is contained in:
parent
f6ab0f8f46
commit
86ab880c90
3 changed files with 49 additions and 14 deletions
|
@ -48,6 +48,7 @@ class AssetFactory extends Factory
|
||||||
'assigned_type' => null,
|
'assigned_type' => null,
|
||||||
'next_audit_date' => null,
|
'next_audit_date' => null,
|
||||||
'last_checkout' => null,
|
'last_checkout' => null,
|
||||||
|
'asset_eol_date' => null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,4 +353,14 @@ class AssetFactory extends Factory
|
||||||
{
|
{
|
||||||
return $this->state(['requestable' => false]);
|
return $this->state(['requestable' => false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function noPurchaseOrEolDate()
|
||||||
|
{
|
||||||
|
return $this->afterCreating(function (Asset $asset) {
|
||||||
|
$asset->update([
|
||||||
|
'purchase_date' => null,
|
||||||
|
'asset_eol_date' => null
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,6 @@ class AssetStoreTest extends TestCase
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertStatusMessageIs('success')
|
->assertStatusMessageIs('success')
|
||||||
->json();
|
->json();
|
||||||
return $response;
|
|
||||||
|
|
||||||
$asset = Asset::find($response['payload']['id']);
|
$asset = Asset::find($response['payload']['id']);
|
||||||
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||||
|
|
|
@ -27,6 +27,16 @@ class AssetUpdateTest extends TestCase
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGivenPermissionUpdateAssetIsAllower()
|
||||||
|
|
||||||
|
{
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->editAssets()->create())
|
||||||
|
->patchJson(route('api.assets.update', $asset->id))
|
||||||
|
->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
public function testAllAssetAttributesAreStored()
|
public function testAllAssetAttributesAreStored()
|
||||||
{
|
{
|
||||||
$asset = Asset::factory()->create();
|
$asset = Asset::factory()->create();
|
||||||
|
@ -89,29 +99,44 @@ class AssetUpdateTest extends TestCase
|
||||||
$this->assertEquals(10, $updatedAsset->warranty_months);
|
$this->assertEquals(10, $updatedAsset->warranty_months);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArchivedDepreciateAndPhysicalCanBeNull()
|
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
||||||
{
|
{
|
||||||
$model = AssetModel::factory()->ipadModel()->create();
|
$model = AssetModel::factory()->mbp13Model()->create();
|
||||||
$status = Statuslabel::factory()->create();
|
|
||||||
$asset = Asset::factory()->create();
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
$this->settings->enableAutoIncrement();
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
||||||
->patchJson(route('api.assets.update', $asset->id), [
|
->patchJson((route('api.assets.update', $asset->id)), [
|
||||||
'archive' => null,
|
'model_id' => $model->id,
|
||||||
'depreciate' => null,
|
'purchase_date' => '2021-01-01',
|
||||||
'physical' => null
|
|
||||||
])
|
])
|
||||||
->dd()
|
//->dd()
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertStatusMessageIs('success')
|
->assertStatusMessageIs('success')
|
||||||
->json();
|
->json();
|
||||||
|
|
||||||
$asset = Asset::find($response['payload']['id']);
|
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||||
$this->assertEquals(0, $asset->archived);
|
}
|
||||||
$this->assertEquals(1, $asset->physical);
|
|
||||||
$this->assertEquals(0, $asset->depreciate);
|
public function testAssetEolDateIsNotCalculatedIfPurchaseDateNotSet()
|
||||||
|
{
|
||||||
|
$asset = Asset::factory()->laptopMbp()->noPurchaseOrEolDate()->create();
|
||||||
|
|
||||||
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
|
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
||||||
|
->patchJson(route('api.assets.update', $asset->id), [
|
||||||
|
'name' => 'test asset',
|
||||||
|
'asset_eol_date' => '2022-01-01'
|
||||||
|
])
|
||||||
|
->assertOk()
|
||||||
|
->assertStatusMessageIs('success')
|
||||||
|
->json();
|
||||||
|
|
||||||
|
$asset->refresh();
|
||||||
|
|
||||||
|
$this->assertEquals('2022-01-01', $asset->asset_eol_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue