add all controllers logic
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Frontend;
|
||||
|
||||
use App\Services\Email\EmailDispatchService;
|
||||
use App\Services\Frontend\ContactSubmissionService;
|
||||
use App\Services\System\GlobalConfigService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContactSubmissionServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_submit_creates_contact_record(): void
|
||||
{
|
||||
DB::table('configuration')->insert([
|
||||
['config_key' => 'school_year', 'config_value' => '2025-2026'],
|
||||
['config_key' => 'semester', 'config_value' => 'Fall'],
|
||||
]);
|
||||
|
||||
$emailService = $this->createMock(EmailDispatchService::class);
|
||||
$emailService->method('send')->willReturn(false);
|
||||
|
||||
$service = new ContactSubmissionService($emailService, new GlobalConfigService());
|
||||
|
||||
$result = $service->submit([
|
||||
'email' => 'contact@example.com',
|
||||
'message' => 'Hello from unit test',
|
||||
]);
|
||||
|
||||
$this->assertNotNull($result['record']);
|
||||
$this->assertDatabaseHas('contactus', [
|
||||
'subject' => 'Contact Us Form Submission',
|
||||
'semester' => 'Fall',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user