snipe-it/tests/Unit/NotificationTest.php
Marcus Moore 3e832e5e94
Revert "Define test classes as final"
This reverts commit 95516b0343.
2024-08-06 13:31:17 -07:00

37 lines
1.1 KiB
PHP

<?php
namespace Tests\Unit;
use App\Models\User;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use Carbon\Carbon;
use App\Notifications\CheckoutAssetNotification;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class NotificationTest extends TestCase
{
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
{
$admin = User::factory()->superuser()->create();
$user = User::factory()->create();
$asset = Asset::factory()
->create(
[
'model_id' => AssetModel::factory()
->create(
[
'category_id' => Category::factory()->assetLaptopCategory()->create()->id
]
)->id,
'warranty_months' => 24,
'purchase_date' => Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0)->format('Y-m-d')
]);
Notification::fake();
$asset->checkOut($user, $admin->id);
Notification::assertSentTo($user, CheckoutAssetNotification::class);
}
}