60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Events;
|
|
|
|
use App\Models\Event;
|
|
use App\Services\Events\EventChargeService;
|
|
use App\Services\Invoices\InvoiceGenerationService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Mockery;
|
|
use Tests\TestCase;
|
|
|
|
class EventChargeServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_seed_charges_creates_event_charges(): void
|
|
{
|
|
DB::table('events')->insert([
|
|
'id' => 1,
|
|
'event_name' => 'Trip',
|
|
'event_category' => 'field trips',
|
|
'amount' => 25,
|
|
'expiration_date' => '2025-02-01',
|
|
'semester' => 'Fall',
|
|
'school_year' => '2025-2026',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
DB::table('students')->insert([
|
|
'id' => 1,
|
|
'parent_id' => 10,
|
|
'firstname' => 'Kid',
|
|
'lastname' => 'One',
|
|
]);
|
|
|
|
DB::table('enrollments')->insert([
|
|
'id' => 1,
|
|
'student_id' => 1,
|
|
'parent_id' => 10,
|
|
'class_section_id' => 101,
|
|
'enrollment_status' => 'enrolled',
|
|
'school_year' => '2025-2026',
|
|
]);
|
|
|
|
$invoiceService = Mockery::mock(InvoiceGenerationService::class);
|
|
$invoiceService->shouldReceive('generateInvoice')->andReturn(['ok' => true]);
|
|
|
|
$service = new EventChargeService($invoiceService);
|
|
$event = Event::query()->findOrFail(1);
|
|
$service->seedChargesForEvent($event, '2025-2026', 'Fall', 25, 1);
|
|
|
|
$this->assertDatabaseHas('event_charges', [
|
|
'event_id' => 1,
|
|
'student_id' => 1,
|
|
]);
|
|
}
|
|
}
|