From 413b68fbe378b4ce307eebc332c8ab0367967687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ba=C5=9F?= Date: Mon, 5 Nov 2018 20:07:40 +0300 Subject: [PATCH] Invoice test and invoice update issue solved --- app/Http/Controllers/Incomes/Invoices.php | 1 + tests/Feature/Incomes/InvoicesTest.php | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index efe8a1b93..dbf628fc1 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -240,6 +240,7 @@ class Invoices extends Controller { $taxes = []; + $tax = 0; $tax_total = 0; $sub_total = 0; $discount_total = 0; diff --git a/tests/Feature/Incomes/InvoicesTest.php b/tests/Feature/Incomes/InvoicesTest.php index 7dc0839a3..272270906 100644 --- a/tests/Feature/Incomes/InvoicesTest.php +++ b/tests/Feature/Incomes/InvoicesTest.php @@ -58,6 +58,7 @@ class InvoicesTest extends FeatureTestCase ->assertStatus(302); $this->assertFlashLevel('success'); + } public function testItShouldDeleteInvoice() @@ -70,25 +71,24 @@ class InvoicesTest extends FeatureTestCase ->assertRedirect(url('incomes/invoices')); $this->assertFlashLevel('success'); + } private function getInvoiceRequest($recurring = 0) { $amount = $this->faker->randomFloat(2, 2); + + $items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']]; + $data = [ - 'company_id' => $this->company->id, 'customer_id' => '0', - 'currency_code' => setting('general.default_currency'), - 'currency_rate' => '1', 'invoiced_at' => $this->faker->date(), 'due_at' => $this->faker->date(), - 'invoice_number' => $this->faker->lexify('INV ???'), - 'order_number' => $this->faker->randomDigit, - 'item_id' => null, - 'item_name' => $this->faker->text(5), - 'item_quantity' => '1', - 'item_price' => $amount, - 'item_currency' => setting('general.default_currency'), + 'invoice_number' => '1', + 'order_number' => '1', + 'currency_code' => setting('general.default_currency'), + 'currency_rate' => '1', + 'item' => $items, 'discount' => '0', 'notes' => $this->faker->text(5), 'category_id' => $this->company->categories()->type('income')->first()->id, @@ -100,6 +100,7 @@ class InvoicesTest extends FeatureTestCase 'customer_address' => $this->faker->address, 'invoice_status_code' => 'draft', 'amount' => $amount, + 'company_id' => $this->company->id, ]; if ($recurring) { @@ -108,6 +109,7 @@ class InvoicesTest extends FeatureTestCase $data['recurring_custom_frequency'] = $this->faker->randomElement(['monthly', 'weekly']); $data['recurring_count'] = '1'; } + return $data; } } \ No newline at end of file