60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Payments;
|
|
|
|
use App\Services\ApplicationUrlService;
|
|
use App\Services\Payments\PaymentEnrollmentEventService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class PaymentEnrollmentEventServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private function makeService(): PaymentEnrollmentEventService
|
|
{
|
|
return new PaymentEnrollmentEventService(new ApplicationUrlService());
|
|
}
|
|
|
|
public function test_build_event_data_requires_parent(): void
|
|
{
|
|
$service = $this->makeService();
|
|
|
|
$this->expectException(\RuntimeException::class);
|
|
|
|
$service->buildEventData(999, [], '2025-2026', 'Fall');
|
|
}
|
|
|
|
public function test_build_event_data_returns_parent_payload_when_no_students(): void
|
|
{
|
|
DB::table('users')->insert([
|
|
'id' => 10,
|
|
'school_id' => 1,
|
|
'firstname' => 'Parent',
|
|
'lastname' => 'User',
|
|
'cellphone' => '555-555-5555',
|
|
'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',
|
|
]);
|
|
|
|
$service = $this->makeService();
|
|
[$parent, $students] = $service->buildEventData(10, [], '2025-2026', 'Fall', 'https://example.test/login');
|
|
|
|
$this->assertSame(10, $parent['user_id']);
|
|
$this->assertSame('parent@example.com', $parent['email']);
|
|
$this->assertSame([], $students);
|
|
}
|
|
}
|