From 5946fac405926968813ac589ecd92140699e05a1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 14 Jul 2021 14:57:43 +1000 Subject: [PATCH] Update support message subject format --- app/Mail/SupportMessageSent.php | 4 +- tests/Feature/UpdatePaymentTest.php | 137 ++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/UpdatePaymentTest.php diff --git a/app/Mail/SupportMessageSent.php b/app/Mail/SupportMessageSent.php index 0f0cf099d7c5..fb634195a004 100644 --- a/app/Mail/SupportMessageSent.php +++ b/app/Mail/SupportMessageSent.php @@ -62,9 +62,9 @@ class SupportMessageSent extends Mailable $user = auth()->user(); if(Ninja::isHosted()) - $subject = "{$priority}Hosted-{$company->db} :: Customer Support - [{$plan}]"; + $subject = "{$priority}Hosted-{$company->db} :: Customer Support - [{$plan}] ".date('M jS, g:ia'); else - $subject = "{$priority}Self Hosted :: Customer Support - [{$plan}]"; + $subject = "{$priority}Self Hosted :: Customer Support - [{$plan}] ".date('M jS, g:ia'); return $this->from(config('mail.from.address'), $user->present()->name()) ->replyTo($user->email, $user->present()->name()) diff --git a/tests/Feature/UpdatePaymentTest.php b/tests/Feature/UpdatePaymentTest.php new file mode 100644 index 000000000000..95e5ffb58bf6 --- /dev/null +++ b/tests/Feature/UpdatePaymentTest.php @@ -0,0 +1,137 @@ +faker = \Faker\Factory::create(); + + $this->makeTestData(); + $this->withoutExceptionHandling(); + + $this->withoutMiddleware( + ThrottleRequests::class + ); + } + + public function testUpdatePaymentClientPaidToDate() + { + + //Create new client + $client = Client::factory()->create([ + 'user_id' => $this->user->id, + 'company_id' => $this->company->id, + ]); + + + $this->assertEquals(0, $client->balance); + $this->assertEquals(0, $client->paid_to_date); + + //Create Invoice + $invoice = InvoiceFactory::create($this->company->id, $this->user->id); //stub the company and user_id + $invoice->client_id = $client->id; + $invoice->line_items = $this->buildLineItems(); + $invoice->uses_inclusive_taxes = false; + $invoice->save(); + $invoice = (new InvoiceSum($invoice))->build()->getInvoice(); + $invoice->save(); + + $this->assertEquals(0, $invoice->balance); + + $invoice->service()->markSent()->save(); + + $this->assertEquals(10, $invoice->balance); + + + //create Unapplied payment via API + + // $data = [ + // 'amount' => $this->invoice->amount, + // 'client_id' => $client->hashed_id, + // 'invoices' => [ + // [ + // 'invoice_id' => $this->invoice->hashed_id, + // 'amount' => $this->invoice->amount, + // ], + // ], + // 'date' => '2020/12/12', + + // ]; + + $data = [ + 'amount' => 10, + 'client_id' => $client->hashed_id + ]; + + $response = null; + + try { + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->post('/api/v1/payments?include=invoices,paymentables', $data); + } catch (ValidationException $e) { + $message = json_decode($e->validator->getMessageBag(), 1); + $this->assertNotNull($message); + } + + // $arr = $response->json(); + // $response->assertStatus(200); + // $payment_id = $arr['data']['id']; + // $payment = Payment::find($this->decodePrimaryKey($payment_id))->first(); + // $payment->load('invoices'); + + // $this->assertNotNull($payment); + // $this->assertNotNull($payment->invoices()); + // $this->assertEquals(1, $payment->invoices()->count()); + + $this->assertEquals(10, $client->fresh()->paid_to_date); + + } + +} \ No newline at end of file