From 8fe03d82c8fd1a05960a7022a328316d63af7489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 13 Jan 2025 17:57:32 +0100 Subject: [PATCH] Tests --- tests/Feature/EInvoice/PeppolApiTest.php | 97 ++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 tests/Feature/EInvoice/PeppolApiTest.php diff --git a/tests/Feature/EInvoice/PeppolApiTest.php b/tests/Feature/EInvoice/PeppolApiTest.php new file mode 100644 index 0000000000..84832e70de --- /dev/null +++ b/tests/Feature/EInvoice/PeppolApiTest.php @@ -0,0 +1,97 @@ +markTestSkipped('Storecove API key not set'); + } + + $this->makeTestData(); + + $this->withoutMiddleware( + ThrottleRequests::class, + ); + } + + public function testGeneratingToken() + { + config(['ninja.environment' => 'selfhost']); + + /** + * @var \App\Models\CompanyUser $user + */ + $user = $this->user; + + $current = $user->account->e_invoicing_token; + + $this->assertNull($current); + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->post('/api/v1/einvoice/token/update') + ->assertSuccessful() + ; + + $user->refresh(); + + $this->assertNotEquals($current, $user->account->e_invoicing_token); + } + + public function testHealthCheck() + { + config(['ninja.environment' => 'selfhost']); + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->get('/api/v1/einvoice/health_check') + ->assertStatus(status: 422) + ; + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->post('/api/v1/einvoice/token/update') + ->assertSuccessful() + ; + + $this + ->withHeaders([ + 'X-API-TOKEN' => $this->token, + ]) + ->get('/api/v1/einvoice/health_check') + ->assertSuccessful() + ; + } +}