76 lines
2.6 KiB
PHP
76 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Administrator;
|
|
|
|
use App\Services\Administrator\AdminNotificationUserService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class AdminNotificationUserServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_fetch_admin_notification_users_excludes_parents(): void
|
|
{
|
|
DB::table('roles')->insert([
|
|
['id' => 1, 'name' => 'Admin', 'slug' => 'admin', 'dashboard_route' => 'admin', 'priority' => 1, 'is_active' => 1],
|
|
['id' => 2, 'name' => 'Parent', 'slug' => 'parent', 'dashboard_route' => 'parent', 'priority' => 2, 'is_active' => 1],
|
|
]);
|
|
|
|
DB::table('users')->insert([
|
|
[
|
|
'id' => 1,
|
|
'school_id' => 1,
|
|
'firstname' => 'Admin',
|
|
'lastname' => 'User',
|
|
'cellphone' => '5555555555',
|
|
'email' => 'admin@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',
|
|
],
|
|
[
|
|
'id' => 2,
|
|
'school_id' => 1,
|
|
'firstname' => 'Parent',
|
|
'lastname' => 'User',
|
|
'cellphone' => '5555555555',
|
|
'email' => 'parent@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('user_roles')->insert([
|
|
['id' => 1, 'user_id' => 1, 'role_id' => 1],
|
|
['id' => 2, 'user_id' => 2, 'role_id' => 2],
|
|
]);
|
|
|
|
$service = new AdminNotificationUserService();
|
|
$admins = $service->fetchAdminNotificationUsers();
|
|
|
|
$this->assertCount(1, $admins);
|
|
$this->assertSame('admin@example.com', $admins[0]['email']);
|
|
}
|
|
}
|