generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f365085
commit 7d44a0f
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
<?php | ||
|
||
todo('write tests for @api'); | ||
use Illuminate\Http\Client\Request; | ||
use Illuminate\Support\Facades\Http; | ||
use Routegroup\Imoje\Payment\DTO\Request\RefundRequestDto; | ||
use Routegroup\Imoje\Payment\Lib\Api; | ||
use Routegroup\Imoje\Payment\Lib\Utils; | ||
|
||
beforeEach(function (): void { | ||
Http::fake(); | ||
$this->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'; | ||
}); | ||
}); |