add controllers, servoices
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Payments;
|
||||
|
||||
use App\Services\Payments\PaymentBalanceService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PaymentBalanceServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_update_balance_adjusts_payment_totals(): 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' => 'cash',
|
||||
'payment_date' => '2025-01-01',
|
||||
'school_year' => '2025-2026',
|
||||
'status' => 'Pending',
|
||||
]);
|
||||
|
||||
$service = new PaymentBalanceService();
|
||||
$updated = $service->updateBalance(1, 40);
|
||||
|
||||
$this->assertTrue($updated);
|
||||
$this->assertDatabaseHas('payments', [
|
||||
'id' => 1,
|
||||
'paid_amount' => 40,
|
||||
'balance' => 60,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user