3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-14 04:15:48 +00:00
Files
snipe-it/tests/Feature/Notifications/Email/EmailNotificationsUponCheckoutTest.php
2025-05-15 13:39:27 -07:00

50 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature\Notifications\Email;
use App\Events\CheckoutableCheckedOut;
use App\Mail\CheckinAssetMail;
use App\Mail\CheckoutAssetMail;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use PHPUnit\Framework\Attributes\Group;
use Tests\TestCase;
#[Group('notifications')]
class EmailNotificationsUponCheckoutTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Mail::fake();
}
public function testAdminCCEmailStillSentWhenCategoryEmailIsNotSetToSendEmailToUser()
{
$this->settings->enableAdminCC('cc@example.com');
$category = Category::factory()->create([
'checkin_email' => false,
'eula_text' => null,
'use_default_eula' => false,
]);
$assetModel = AssetModel::factory()->create(['category_id' => $category->id]);
$asset = Asset::factory()->create(['model_id' => $assetModel->id]);
event(new CheckoutableCheckedOut(
$asset,
User::factory()->create(),
User::factory()->superuser()->create(),
'',
));
Mail::assertSent(CheckoutAssetMail::class, function ($mail) {
return $mail->hasTo('cc@example.com');
});
}
}