3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-15 10:05:43 +00:00
Files
snipe-it/tests/Feature/Notifications/Email/CheckoutResponseEmailTest.php
2025-06-05 16:44:44 -07:00

62 lines
1.6 KiB
PHP

<?php
namespace Tests\Feature\Notifications\Email;
use App\Mail\CheckoutAcceptanceResponseMail;
use App\Models\CheckoutAcceptance;
use App\Models\User;
use Illuminate\Support\Facades\Mail;
use Tests\TestCase;
class CheckoutResponseEmailTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Mail::fake();
}
public function test_accepting_checkout_acceptance_configured_to_send_alert()
{
$user = User::factory()->create();
$checkoutAcceptance = CheckoutAcceptance::factory()
->pending()
->create([
'alert_on_response_id' => $user->id,
]);
$this->actingAs($checkoutAcceptance->assignedTo)
->post(route('account.store-acceptance', $checkoutAcceptance), [
'asset_acceptance' => 'accepted',
'note' => null,
]);
$this->assertEmailSentTo($user);
}
public function test_declining_checkout_acceptance_configured_to_send_alert()
{
$this->markTestIncomplete();
}
public function test_accepting_checkout_acceptance_not_configured_to_send_alert()
{
$this->markTestIncomplete();
}
public function test_declining_checkout_acceptance_not_configured_to_send_alert()
{
$this->markTestIncomplete();
}
private function assertEmailSentTo(User $user): void
{
Mail::assertSent(CheckoutAcceptanceResponseMail::class, function ($mail) use ($user) {
// @todo: better assertions? accepted vs declined?
return $mail->hasTo($user->email);
});
}
}