02ba2fe6b6
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
140 lines
4.8 KiB
PHP
140 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Services\Payments;
|
|
|
|
use App\Services\Discounts\DiscountInvoiceService;
|
|
use App\Services\Payments\PaymentEnrollmentEventService;
|
|
use App\Services\Payments\PaymentManualService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Mockery;
|
|
use Tests\TestCase;
|
|
|
|
class PaymentManualServiceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_record_payment_rejects_invalid_method(): void
|
|
{
|
|
$invoiceService = Mockery::mock(DiscountInvoiceService::class);
|
|
$enrollmentService = Mockery::mock(PaymentEnrollmentEventService::class);
|
|
|
|
$service = new PaymentManualService($invoiceService, $enrollmentService);
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
$service->recordPayment(1, 10.0, 'wire', null, null, null, null);
|
|
}
|
|
|
|
public function test_suggest_returns_matches(): 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',
|
|
]);
|
|
|
|
$invoiceService = Mockery::mock(DiscountInvoiceService::class);
|
|
$enrollmentService = Mockery::mock(PaymentEnrollmentEventService::class);
|
|
|
|
$service = new PaymentManualService($invoiceService, $enrollmentService);
|
|
$results = $service->suggest('parent@example.com');
|
|
|
|
$this->assertCount(1, $results);
|
|
$this->assertSame('parent@example.com', $results[0]['value']);
|
|
}
|
|
|
|
public function test_suggest_returns_matches_in_display_name_order(): void
|
|
{
|
|
DB::table('users')->insert([
|
|
[
|
|
'id' => 10,
|
|
'school_id' => 1,
|
|
'firstname' => 'Zara',
|
|
'lastname' => 'Akter',
|
|
'cellphone' => '555-555-5555',
|
|
'email' => 'zara.akter@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',
|
|
],
|
|
[
|
|
'id' => 11,
|
|
'school_id' => 1,
|
|
'firstname' => 'Aisha',
|
|
'lastname' => 'Akter',
|
|
'cellphone' => '555-555-5556',
|
|
'email' => 'aisha.akter@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',
|
|
],
|
|
[
|
|
'id' => 12,
|
|
'school_id' => 1,
|
|
'firstname' => 'Mousumi',
|
|
'lastname' => 'Akter',
|
|
'cellphone' => '555-555-5557',
|
|
'email' => 'mousumi.akter@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',
|
|
],
|
|
]);
|
|
|
|
$invoiceService = Mockery::mock(DiscountInvoiceService::class);
|
|
$enrollmentService = Mockery::mock(PaymentEnrollmentEventService::class);
|
|
|
|
$service = new PaymentManualService($invoiceService, $enrollmentService);
|
|
$results = $service->suggest('akter');
|
|
|
|
$this->assertSame([
|
|
'Aisha Akter',
|
|
'Mousumi Akter',
|
|
'Zara Akter',
|
|
], array_column($results, 'label'));
|
|
}
|
|
}
|