add more controllers and fix tests

This commit is contained in:
root
2026-03-09 11:54:13 -04:00
parent 0c3e9b16f7
commit 1cb3573d4b
74 changed files with 2761 additions and 2728 deletions
@@ -0,0 +1,58 @@
<?php
namespace Tests\Unit\Services\Email;
use App\Services\Email\EmailExtractorService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class EmailExtractorServiceTest extends TestCase
{
use RefreshDatabase;
public function test_list_and_compare_emails(): void
{
DB::table('users')->insert([
'id' => 1,
'school_id' => 1,
'firstname' => 'User',
'lastname' => 'One',
'cellphone' => '5555555555',
'email' => 'user1@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' => 1,
'secondparent_id' => 2,
'school_year' => '2025-2026',
]);
$service = new EmailExtractorService();
$emails = $service->listEmails();
$this->assertContains('user1@example.com', $emails['users']);
$this->assertContains('parent2@example.com', $emails['parents']);
$result = $service->compare(['user1@example.com', 'missing@example.com']);
$this->assertContains('user1@example.com', $result['existed']);
$this->assertContains('parent2@example.com', $result['needToAdd']);
}
}
@@ -0,0 +1,33 @@
<?php
namespace Tests\Unit\Services\Email;
use App\Services\Email\EmailProfileService;
use Tests\TestCase;
class EmailProfileServiceTest extends TestCase
{
public function test_resolve_profile_maps_aliases(): void
{
$service = new EmailProfileService();
$this->assertSame('communication', $service->resolveProfile('comm'));
$this->assertSame('default', $service->resolveProfile('system'));
$this->assertSame('payment', $service->resolveProfile('payment'));
}
public function test_env_key_from_profile(): void
{
$service = new EmailProfileService();
$this->assertSame('PAYMENT_ALERTS', $service->envKeyFromProfile('payment alerts'));
}
public function test_sanitize_reply_to_name(): void
{
$service = new EmailProfileService();
$this->assertSame('Fallback', $service->sanitizeReplyToName('no-reply', 'Fallback'));
$this->assertSame('Support', $service->sanitizeReplyToName('Support', 'Fallback'));
}
}