From 7d44a0f00d822408bb1d2e6babd87f79cad1b8c0 Mon Sep 17 00:00:00 2001 From: Kajetan Nobel Date: Thu, 21 Sep 2023 20:50:27 +0200 Subject: [PATCH] feat: adds tests for Lib/Api --- composer.json | 1 + tests/Lib/ApiTest.php | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index aafb95c..55dced9 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": "^8.1", + "guzzlehttp/guzzle": "^7.8", "illuminate/support": "^10.0", "justinrainbow/json-schema": "^5.2" }, diff --git a/tests/Lib/ApiTest.php b/tests/Lib/ApiTest.php index 3a12ed3..e52750f 100644 --- a/tests/Lib/ApiTest.php +++ b/tests/Lib/ApiTest.php @@ -1,3 +1,35 @@ api = app(Api::class); + $this->utils = app(Utils::class); +}); + +it('makes refund request', function (): void { + $dto = RefundRequestDto::make(['amount' => 100]); + $this->api->createRefund($dto, '$transaction_id$'); + + Http::assertSent(function (Request $request) { + return $request->url() === $this->utils->createRefundUrl('$transaction_id$') + && $request->isJson() + && $request->method() === 'POST' + && array_keys($request->data()) === ['type', 'serviceId', 'amount']; + }); +}); + +it('makes deactivate profile request', function (): void { + $this->api->deactivateProfile('$profile_id$'); + + Http::assertSent(function (Request $request) { + return $request->url() === $this->utils->createDeactivateProfileUrl('$profile_id$') + && $request->isJson() + && $request->method() === 'DELETE'; + }); +});