2017-08-31 11:14:21 -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\Models\User;
|
2021-12-02 20:01:03 -08:00
|
|
|
use App\Models\Asset;
|
|
|
|
use App\Models\AssetModel;
|
|
|
|
use App\Models\Category;
|
|
|
|
use Carbon\Carbon;
|
2018-03-25 13:46:57 -07:00
|
|
|
use App\Notifications\CheckoutAssetNotification;
|
2017-08-31 11:14:21 -07:00
|
|
|
use Illuminate\Support\Facades\Notification;
|
2023-03-07 16:57:55 -08:00
|
|
|
use Tests\TestCase;
|
2021-12-02 20:01:03 -08:00
|
|
|
|
2023-03-07 16:57:55 -08:00
|
|
|
class NotificationTest extends TestCase
|
2017-08-31 11:14:21 -07:00
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
|
|
|
{
|
2023-03-06 12:40:47 -08:00
|
|
|
$admin = User::factory()->superuser()->create();
|
2021-12-02 20:01:03 -08:00
|
|
|
$user = User::factory()->create();
|
|
|
|
$asset = Asset::factory()
|
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'model_id' => AssetModel::factory()
|
|
|
|
->create(
|
|
|
|
[
|
|
|
|
'category_id' => Category::factory()->assetLaptopCategory()->id
|
|
|
|
]
|
2023-03-02 13:47:58 -08:00
|
|
|
)->id,
|
2021-12-02 20:01:03 -08:00
|
|
|
'warranty_months' => 24,
|
2023-03-02 13:47:58 -08:00
|
|
|
'purchase_date' => Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0)->format('Y-m-d')
|
2021-12-02 20:01:03 -08:00
|
|
|
]);
|
|
|
|
|
2020-04-27 18:02:14 -07:00
|
|
|
Notification::fake();
|
2023-03-06 12:40:47 -08:00
|
|
|
$asset->checkOut($user, $admin->id);
|
2020-04-27 18:02:14 -07:00
|
|
|
Notification::assertSentTo($user, CheckoutAssetNotification::class);
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2017-08-31 11:14:21 -07:00
|
|
|
}
|