add whatsup logic
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Whatsapp;
|
||||
|
||||
use App\Services\Whatsapp\WhatsappContactService;
|
||||
use App\Services\Whatsapp\WhatsappContextService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WhatsappContactServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_list_parent_contacts_returns_primary_and_second(): void
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
'id' => 10,
|
||||
'school_id' => 1,
|
||||
'firstname' => 'Parent',
|
||||
'lastname' => 'One',
|
||||
'cellphone' => '5555555555',
|
||||
'email' => 'parent1@example.com',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'is_verified' => 1,
|
||||
'status' => 'Active',
|
||||
'is_suspended' => 0,
|
||||
'failed_attempts' => 0,
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('parents')->insert([
|
||||
'secondparent_firstname' => 'Parent',
|
||||
'secondparent_lastname' => 'Two',
|
||||
'secondparent_email' => 'parent2@example.com',
|
||||
'secondparent_phone' => '5555555555',
|
||||
'firstparent_id' => 10,
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$service = new WhatsappContactService(new WhatsappContextService());
|
||||
$contacts = $service->listParentContacts('2025-2026', 'Fall');
|
||||
|
||||
$this->assertCount(2, $contacts);
|
||||
$this->assertSame('Primary Parent', $contacts[0]['type']);
|
||||
$this->assertSame('Second Parent', $contacts[1]['type']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user