From f5dfb69776f1ccacd1e9e1cc65ce27780100c7f8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 17 Sep 2023 19:24:15 +1000 Subject: [PATCH] Tests for payments --- tests/Feature/PaymentTest.php | 37 ++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tests/Feature/PaymentTest.php b/tests/Feature/PaymentTest.php index e62ea4502b05..1dcdd8f49fa9 100644 --- a/tests/Feature/PaymentTest.php +++ b/tests/Feature/PaymentTest.php @@ -62,6 +62,40 @@ class PaymentTest extends TestCase ); } + + public function testCompletedPaymentLogic() + { + $payment = Payment::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'client_id' => $this->client->id, + 'status_id' => Payment::STATUS_COMPLETED, + 'amount' => 100 + ]); + + $data = [ + 'amount' => $this->invoice->amount, + 'client_id' => $this->client->hashed_id, + 'invoices' => [ + [ + 'invoice_id' => $this->invoice->hashed_id, + 'amount' => $this->invoice->amount, + ], + ], + 'date' => '2020/12/11', + 'idempotency_key' => 'dsjafhajklsfhlaksjdhlkajsdjdfjdfljasdfhkjlsafhljfkfhsjlfhiuwayerfiuwaskjgbzmvnjzxnjcbgfkjhdgfoiwwrasdfasdfkashjdfkaskfjdasfda' + + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->putJson('/api/v1/payments/'.$payment->hashed_id, $data); + + $response->assertStatus(200); + + } + public function testPendingPaymentLogic() { $payment = Payment::factory()->create([ @@ -95,9 +129,6 @@ class PaymentTest extends TestCase } - - - public function testPaymentGetBetweenQuery1() { $response = $this->withHeaders([