diff --git a/tests/Feature/RecurringInvoiceTest.php b/tests/Feature/RecurringInvoiceTest.php index b995bc47e135..2c076d214d2e 100644 --- a/tests/Feature/RecurringInvoiceTest.php +++ b/tests/Feature/RecurringInvoiceTest.php @@ -11,6 +11,7 @@ namespace Tests\Feature; +use App\Factory\InvoiceItemFactory; use App\Factory\InvoiceToRecurringInvoiceFactory; use App\Factory\RecurringInvoiceToInvoiceFactory; use App\Models\Client; @@ -51,6 +52,51 @@ class RecurringInvoiceTest extends TestCase $this->makeTestData(); } + public function testPostRecurringInvoiceWithPlaceholderVariables() + { + $line_items = []; + + $item = InvoiceItemFactory::create(); + $item->quantity = 1; + $item->cost = 10; + $item->task_id = $this->encodePrimaryKey($this->task->id); + $item->expense_id = $this->encodePrimaryKey($this->expense->id); + $item->description = "Hello this is the month of :MONTH"; + + $line_items[] = $item; + + + $data = [ + 'frequency_id' => 1, + 'status_id' => 1, + 'discount' => 0, + 'is_amount_discount' => 1, + 'po_number' => '3434343', + 'public_notes' => 'notes', + 'is_deleted' => 0, + 'custom_value1' => 0, + 'custom_value2' => 0, + 'custom_value3' => 0, + 'custom_value4' => 0, + 'status' => 1, + 'client_id' => $this->encodePrimaryKey($this->client->id), + 'line_items' => $line_items, + 'remaining_cycles' => -1, + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/recurring_invoices/', $data) + ->assertStatus(200); + + $arr = $response->json(); + $this->assertEquals(RecurringInvoice::STATUS_DRAFT, $arr['data']['status_id']); + + $this->assertIsArray($arr['data']['line_items']); + } + + public function testPostRecurringInvoice() { $data = [