add whatsup logic
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user