Files
alrahma_sunday_school_api/tests/Unit/Services/Whatsapp/WhatsappInviteNotificationServiceTest.php
T
2026-06-09 01:03:53 -04:00

40 lines
1.2 KiB
PHP

<?php
namespace Tests\Unit\Services\Whatsapp;
use App\Events\WhatsappInvitesSend;
use App\Services\Whatsapp\WhatsappInviteNotificationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class WhatsappInviteNotificationServiceTest extends TestCase
{
use RefreshDatabase;
public function test_dispatch_returns_error_when_no_listeners(): void
{
$service = new WhatsappInviteNotificationService();
$result = $service->dispatch([], '2025-2026', 'Fall');
$this->assertFalse($result['ok']);
}
public function test_dispatch_triggers_event_when_listener_registered(): void
{
Event::listen(WhatsappInvitesSend::class, static function () {
});
$service = new WhatsappInviteNotificationService();
$result = $service->dispatch([[
'parent' => ['id' => 10],
'emails' => ['parent1@example.com'],
'sections' => [],
'links' => ['https://chat.whatsapp.com/abc'],
]], '2025-2026', 'Fall');
$this->assertTrue($result['ok']);
$this->assertSame(1, $result['triggered']);
}
}