From 4a627be02c2798dc2eb4ca0b4fe2193a252b9c11 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 28 Apr 2024 15:05:30 +1000 Subject: [PATCH] Tests for credit payments --- app/Services/Payment/DeletePayment.php | 1 - tests/Feature/CreditTest.php | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/Services/Payment/DeletePayment.php b/app/Services/Payment/DeletePayment.php index 8d371f4efed4..c7d0a63270c6 100644 --- a/app/Services/Payment/DeletePayment.php +++ b/app/Services/Payment/DeletePayment.php @@ -70,7 +70,6 @@ class DeletePayment /** @return $this */ private function deletePaymentables() { - // $this->payment->paymentables()->update(['deleted_at' => now()]); $this->payment->paymentables() ->each(function ($pp) { diff --git a/tests/Feature/CreditTest.php b/tests/Feature/CreditTest.php index e899979a8d64..28aba2164bda 100644 --- a/tests/Feature/CreditTest.php +++ b/tests/Feature/CreditTest.php @@ -105,10 +105,12 @@ class CreditTest extends TestCase $this->assertEquals(100, $i->balance); $this->assertEquals(100, $i->amount); $this->assertEquals(0, $i->paid_to_date); - + $this->assertEquals(2, $i->status_id); + $this->assertEquals(100, $cr->balance); $this->assertEquals(100, $cr->amount); $this->assertEquals(0, $cr->paid_to_date); + $this->assertEquals(2, $cr->status_id); $this->assertEquals(100, $c->balance); $this->assertEquals(0, $c->paid_to_date); @@ -145,9 +147,11 @@ class CreditTest extends TestCase $this->assertEquals(0, $i->balance); $this->assertEquals(100, $i->paid_to_date); + $this->assertEquals(4, $i->status_id); $this->assertEquals(0, $cr->balance); $this->assertEquals(100, $cr->paid_to_date); + $this->assertEquals(4, $i->status_id); $this->assertEquals(100, $c->paid_to_date); $this->assertEquals(0, $c->balance); @@ -171,14 +175,32 @@ class CreditTest extends TestCase $this->assertEquals(100, $i->balance); $this->assertEquals(100, $i->amount); $this->assertEquals(0, $i->paid_to_date); + $this->assertEquals(2, $i->status_id); $this->assertEquals(100, $cr->balance); $this->assertEquals(100, $cr->amount); + $this->assertEquals(2, $cr->status_id); $this->assertEquals(0, $cr->paid_to_date); $this->assertEquals(100, $c->balance); $this->assertEquals(0, $c->paid_to_date); + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->deleteJson("/api/v1/credits/{$cr->hashed_id}"); + + $response->assertStatus(200); + + $cr = $cr->fresh(); + + $this->assertEquals(true, $cr->is_deleted); + + $this->assertEquals(100, $c->balance); + $this->assertEquals(0, $c->paid_to_date); + + } public function testApplicableFilters()