mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
fixed eol, add calculated eol/eol explicit tests
This commit is contained in:
parent
9d8433bd6d
commit
c3492f1699
|
@ -545,7 +545,7 @@ class AssetsController extends Controller
|
||||||
$asset->user_id = Auth::id();
|
$asset->user_id = Auth::id();
|
||||||
// @todo: verify eol is working as expected - move to request? or do I want this at all?
|
// @todo: verify eol is working as expected - move to request? or do I want this at all?
|
||||||
// might just remove this and then use the method from here https://github.com/snipe/snipe-it/pull/13846
|
// might just remove this and then use the method from here https://github.com/snipe/snipe-it/pull/13846
|
||||||
//$asset->asset_eol_date = $request->validated()['asset_eol_date'] ?? $asset->present()->eol_date();
|
$asset->asset_eol_date = $request->validated()['asset_eol_date'] ?? $asset->present()->eol_date();
|
||||||
$asset->archived = '0';
|
$asset->archived = '0';
|
||||||
$asset->physical = '1';
|
$asset->physical = '1';
|
||||||
$asset->depreciate = '0';
|
$asset->depreciate = '0';
|
||||||
|
|
|
@ -95,6 +95,66 @@ class AssetStoreTest extends TestCase
|
||||||
$this->assertEquals(10, $asset->warranty_months);
|
$this->assertEquals(10, $asset->warranty_months);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAssetEolDateIsCalculatedIfPurchaseDateSet()
|
||||||
|
{
|
||||||
|
$model = AssetModel::factory()->mbp13Model()->create();
|
||||||
|
$status = Statuslabel::factory()->create();
|
||||||
|
|
||||||
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->postJson(route('api.assets.store'), [
|
||||||
|
'model_id' => $model->id,
|
||||||
|
'purchase_date' => '2021-01-01',
|
||||||
|
'status_id' => $status->id,
|
||||||
|
])
|
||||||
|
->assertOk()
|
||||||
|
->assertStatusMessageIs('success');
|
||||||
|
|
||||||
|
$asset = Asset::first();
|
||||||
|
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetEolDateIsNotCalculatedIfPurchaseDateNotSet()
|
||||||
|
{
|
||||||
|
$model = AssetModel::factory()->mbp13Model()->create();
|
||||||
|
$status = Statuslabel::factory()->create();
|
||||||
|
|
||||||
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->postJson(route('api.assets.store'), [
|
||||||
|
'model_id' => $model->id,
|
||||||
|
'status_id' => $status->id,
|
||||||
|
])
|
||||||
|
->assertOk()
|
||||||
|
->assertStatusMessageIs('success');
|
||||||
|
|
||||||
|
$asset = Asset::first();
|
||||||
|
$this->assertNull($asset->asset_eol_date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetEolExplicitIsSetIfAssetEolDateIsSet()
|
||||||
|
{
|
||||||
|
$model = AssetModel::factory()->mbp13Model()->create();
|
||||||
|
$status = Statuslabel::factory()->create();
|
||||||
|
|
||||||
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
->postJson(route('api.assets.store'), [
|
||||||
|
'model_id' => $model->id,
|
||||||
|
'asset_eol_date' => '2025-01-01',
|
||||||
|
'status_id' => $status->id,
|
||||||
|
])
|
||||||
|
->assertOk()
|
||||||
|
->assertStatusMessageIs('success');
|
||||||
|
|
||||||
|
$asset = Asset::first();
|
||||||
|
$this->assertEquals('2025-01-01', $asset->asset_eol_date);
|
||||||
|
$this->assertTrue($asset->eol_explicit);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAssetGetsAssetTagWithAutoIncrement()
|
public function testAssetGetsAssetTagWithAutoIncrement()
|
||||||
{
|
{
|
||||||
$model = AssetModel::factory()->create();
|
$model = AssetModel::factory()->create();
|
||||||
|
|
Loading…
Reference in a new issue