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
|
|
|
|
2017-08-31 11:14:21 -07:00
|
|
|
use App\Exceptions\CheckoutNotAllowed;
|
2016-03-25 01:18:05 -07:00
|
|
|
use App\Models\Asset;
|
2017-06-12 17:39:03 -07:00
|
|
|
use App\Models\AssetModel;
|
|
|
|
use App\Models\Company;
|
2017-08-31 11:14:21 -07:00
|
|
|
use App\Models\Location;
|
2017-09-18 16:40:13 -07:00
|
|
|
use App\Models\User;
|
2021-12-02 17:38:28 -08:00
|
|
|
use App\Models\Category;
|
2018-07-23 06:48:21 -07:00
|
|
|
use Carbon\Carbon;
|
2016-03-25 01:18:05 -07:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2017-06-12 17:39:03 -07:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
2021-11-30 20:09:29 -08:00
|
|
|
use Tests\Unit\BaseTest;
|
2021-12-02 16:14:45 -08:00
|
|
|
use App\Models\Component;
|
|
|
|
use App\Models\ActionLog;
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2017-07-11 20:37:02 -07:00
|
|
|
class AssetTest extends BaseTest
|
2016-03-25 01:18:05 -07:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \UnitTester
|
|
|
|
*/
|
|
|
|
protected $tester;
|
|
|
|
|
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(
|
|
|
|
[
|
|
|
|
'category_id' => Category::factory()->assetLaptopCategory()->id
|
|
|
|
]
|
|
|
|
)->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
|
|
|
}
|