From b2d4b7212b356939c2ff73a989e1a248b654891a Mon Sep 17 00:00:00 2001 From: harshjagad20 Date: Wed, 2 Jun 2021 16:25:20 +0530 Subject: [PATCH] Added invoice test with negative tax --- tests/Feature/InvoiceTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index 8e2bd17e..a552bb56 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -257,3 +257,31 @@ test('clone invoice', function () { 'success' => true, ]); }); + +test('create invoice with negative tax', function () { + $invoice = Invoice::factory() + ->raw([ + 'taxes' => [Tax::factory()->raw([ + 'percent' => -9.99 + ])], + 'items' => [InvoiceItem::factory()->raw()], + ]); + + $response = postJson('api/v1/invoices', $invoice); + + $response->assertOk(); + + $this->assertDatabaseHas('invoices', [ + 'invoice_number' => $invoice['invoice_number'], + 'sub_total' => $invoice['sub_total'], + 'total' => $invoice['total'], + 'tax' => $invoice['tax'], + 'discount' => $invoice['discount'], + 'user_id' => $invoice['user_id'], + 'invoice_template_id' => $invoice['invoice_template_id'], + ]); + + $this->assertDatabaseHas('invoice_items', $invoice['items'][0]); + + $this->assertDatabaseHas('taxes', $invoice['taxes'][0]); +});