add controllers, servoices
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Payments;
|
||||
|
||||
use App\Services\Payments\PaypalPaymentService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PaypalPaymentServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_create_payment_falls_back_to_hosted_when_sdk_missing(): void
|
||||
{
|
||||
DB::table('payments')->insert([
|
||||
'id' => 1,
|
||||
'parent_id' => 10,
|
||||
'invoice_id' => 1,
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 0,
|
||||
'balance' => 100,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'card',
|
||||
'payment_date' => '2025-01-01',
|
||||
'school_year' => '2025-2026',
|
||||
'status' => 'Pending',
|
||||
]);
|
||||
|
||||
$service = new PaypalPaymentService();
|
||||
$result = $service->createPayment(1);
|
||||
|
||||
$this->assertSame('hosted', $result['mode']);
|
||||
$this->assertSame($service->getRedirectUrl(), $result['redirect_url']);
|
||||
}
|
||||
|
||||
public function test_execute_payment_throws_when_sdk_missing(): void
|
||||
{
|
||||
$service = new PaypalPaymentService();
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
$service->executePayment('payer');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user