Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/PaymentTest.php
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public function testCredit(): void | ||||
$this->assertSame($payment1->credit_amount, $transaction->amount); | $this->assertSame($payment1->credit_amount, $transaction->amount); | ||||
$this->assertSame("Payment transaction {$payment1->id} using Test1", $transaction->description); | $this->assertSame("Payment transaction {$payment1->id} using Test1", $transaction->description); | ||||
$wallet->transactions()->delete(); | $wallet->transactions()->delete(); | ||||
$wallet->setSetting('mandate_disabled', 1); | $wallet->setSetting('mandate_disabled', 1); | ||||
$wallet->balance = -5000; | $wallet->balance = -5000; | ||||
$wallet->save(); | $wallet->save(); | ||||
// Credit the 2nd payment | // Credit the 2nd payment (restricted user) | ||||
$user->restrict(); | |||||
$payment2->credit('Test2'); | $payment2->credit('Test2'); | ||||
$wallet->refresh(); | $wallet->refresh(); | ||||
$transaction = $wallet->transactions()->first(); | $transaction = $wallet->transactions()->first(); | ||||
$this->assertSame($payment2->credit_amount - 5000, $wallet->balance); | $this->assertSame($payment2->credit_amount - 5000, $wallet->balance); | ||||
$this->assertSame('1', $wallet->getSetting('mandate_disabled')); | $this->assertSame('1', $wallet->getSetting('mandate_disabled')); | ||||
$this->assertSame($payment2->credit_amount, $transaction->amount); | $this->assertSame($payment2->credit_amount, $transaction->amount); | ||||
$this->assertSame("Auto-payment transaction {$payment2->id} using Test2", $transaction->description); | $this->assertSame("Auto-payment transaction {$payment2->id} using Test2", $transaction->description); | ||||
$this->assertFalse($user->refresh()->isRestricted()); | |||||
} | } | ||||
/** | /** | ||||
* Test createFromArray() and refund() methods | * Test createFromArray() and refund() methods | ||||
*/ | */ | ||||
public function testCreateAndRefund(): void | public function testCreateAndRefund(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |