add all controllers logic

This commit is contained in:
root
2026-03-11 17:53:15 -04:00
parent 3e6c577085
commit 2ef71cc92b
421 changed files with 12009 additions and 5211 deletions
@@ -0,0 +1,27 @@
<?php
namespace Tests\Unit\Services\Support;
use App\Services\Email\EmailDispatchService;
use App\Services\Support\ContactMessageService;
use Tests\TestCase;
class ContactMessageServiceTest extends TestCase
{
public function test_send_returns_payload(): void
{
$mailer = $this->createMock(EmailDispatchService::class);
$mailer->method('send')->willReturn(false);
$service = new ContactMessageService($mailer);
$result = $service->send([
'name' => 'Test User',
'email' => 'test@example.com',
'subject' => 'Hello',
'message' => 'Message',
]);
$this->assertArrayHasKey('email_sent', $result);
$this->assertArrayHasKey('recipient', $result);
}
}
@@ -0,0 +1,55 @@
<?php
namespace Tests\Unit\Services\Support;
use App\Models\User;
use App\Services\Email\EmailDispatchService;
use App\Services\Support\SupportRequestService;
use App\Services\System\GlobalConfigService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class SupportRequestServiceTest extends TestCase
{
use RefreshDatabase;
public function test_create_persists_request(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => 'supporter@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'status' => 'Active',
'password' => bcrypt('secret'),
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$mailer = $this->createMock(EmailDispatchService::class);
$mailer->method('send')->willReturn(false);
$service = new SupportRequestService(new GlobalConfigService(), $mailer);
$result = $service->create($user->id, [
'subject' => 'Help',
'message' => 'Need assistance',
]);
$this->assertNotNull($result['record']);
$this->assertDatabaseHas('support_requests', [
'user_id' => $user->id,
'subject' => 'Help',
]);
}
}