2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
2021-11-30 20:09:29 -08:00
|
|
|
namespace Tests\Unit;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
use App\Models\Asset;
|
2017-06-12 17:39:03 -07:00
|
|
|
use App\Models\AssetModel;
|
2021-12-02 17:38:28 -08:00
|
|
|
use App\Models\Category;
|
2018-07-23 06:48:21 -07:00
|
|
|
use Carbon\Carbon;
|
2023-05-01 16:05:26 -07:00
|
|
|
use Tests\Support\InteractsWithSettings;
|
2023-03-07 16:57:55 -08:00
|
|
|
use Tests\TestCase;
|
2021-12-02 16:14:45 -08:00
|
|
|
|
2023-03-07 16:57:55 -08:00
|
|
|
class AssetTest extends TestCase
|
2016-03-25 01:18:05 -07:00
|
|
|
{
|
2023-05-01 16:05:26 -07:00
|
|
|
use InteractsWithSettings;
|
|
|
|
|
2021-12-02 17:38:28 -08:00
|
|
|
// public function testAutoIncrementMixed()
|
|
|
|
// {
|
|
|
|
// $expected = '123411';
|
|
|
|
// $next = Asset::nextAutoIncrement(
|
|
|
|
// collect([
|
|
|
|
// ['asset_tag' => '0012345'],
|
|
|
|
// ['asset_tag' => 'WTF00134'],
|
|
|
|
// ['asset_tag' => 'WTF-745'],
|
|
|
|
// ['asset_tag' => '0012346'],
|
|
|
|
// ['asset_tag' => '00123410'],
|
|
|
|
// ['asset_tag' => 'U8T7597h77'],
|
|
|
|
// ])
|
|
|
|
// );
|
|
|
|
|
|
|
|
// \Log::debug('Next: '.$next);
|
|
|
|
// $this->assertEquals($expected, $next);
|
|
|
|
// }
|
2017-03-14 08:37:39 -07:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
public function testWarrantyExpiresAttribute()
|
|
|
|
{
|
2021-12-02 17:38:28 -08:00
|
|
|
|
|
|
|
$asset = Asset::factory()
|
|
|
|
->create(
|
|
|
|
[
|
2021-12-02 18:27:52 -08:00
|
|
|
'model_id' => AssetModel::factory()
|
|
|
|
->create(
|
|
|
|
[
|
2023-03-13 16:45:43 -07:00
|
|
|
'category_id' => Category::factory()->assetLaptopCategory()->create()->id
|
2021-12-02 18:27:52 -08:00
|
|
|
]
|
|
|
|
)->id,
|
|
|
|
'warranty_months' => 24,
|
|
|
|
'purchase_date' => Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0)
|
2021-12-02 17:38:28 -08:00
|
|
|
]);
|
|
|
|
|
2021-12-02 18:27:52 -08:00
|
|
|
|
|
|
|
$this->assertEquals(Carbon::createFromDate(2017, 1, 1)->format('Y-m-d'), $asset->purchase_date->format('Y-m-d'));
|
|
|
|
$this->assertEquals(Carbon::createFromDate(2019, 1, 1)->format('Y-m-d'), $asset->warranty_expires->format('Y-m-d'));
|
2018-07-23 06:48:21 -07:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|