Skip to content

Commit

Permalink
feat: add tests for lib/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
kajetan-nobel committed Sep 21, 2023
1 parent af27709 commit f365085
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
5 changes: 0 additions & 5 deletions tests/ExampleTest.php

This file was deleted.

3 changes: 3 additions & 0 deletions tests/Lib/ApiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

todo('write tests for @api');
33 changes: 33 additions & 0 deletions tests/Lib/UtilsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Routegroup\Imoje\Payment\Lib\Utils;

beforeEach(function (): void {
$this->utils = app(Utils::class);
});

it('creates signature')
->expect(fn () => $this->utils->createSignature([
'bar' => 'baz',
'foo' => 'faa',
]))
->toEqual('df8bdc2e4d0d93be22222ea57b5b0e196b897629e9089f05baadffee96baa90d;sha256');

it('builds query for create signature')
->expect(fn () => $this->utils->buildQuery([
'bar' => 'baz',
'foo' => 'faa',
]))
->toEqual('bar=baz&foo=faa');

it('creates refund url')
->expect(fn () => $this->utils->createRefundUrl('$transaction_id$'))
->toEqual('https://sandbox.api.imoje.pl/v1/merchant/$merchant_id$/transaction/$transaction_id$/refund');

it('creates charge profile url')
->expect(fn () => $this->utils->createChargeProfileUrl())
->toEqual('https://sandbox.api.imoje.pl/v1/merchant/$merchant_id$/transaction/profile');

it('creates deactivate profile url')
->expect(fn () => $this->utils->createDeactivateProfileUrl('$profile_id$'))
->toEqual('https://sandbox.api.imoje.pl/v1/merchant/$merchant_id$/profile/id/$profile_id$');
3 changes: 3 additions & 0 deletions tests/Lib/ValidateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

todo('write tests for @validate');
9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Orchestra\Testbench\TestCase as Orchestra;
use Routegroup\Imoje\Payment\ImojeServiceProvider;
use Routegroup\Imoje\Payment\Types\Environment;

class TestCase extends Orchestra
{
Expand All @@ -17,5 +18,13 @@ protected function getPackageProviders($app)
public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'testing');

config()->set('services.imoje', [
'merchant_id' => '$merchant_id$',
'service_id' => '$service_id$',
'service_key' => '$service_key$',
'api_key' => '$api_key$',
'env' => Environment::SANDBOX->value,
]);
}
}

0 comments on commit f365085

Please sign in to comment.