-
-
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.
Merge pull request #9 from njoguamos/add-unit-tests
Add unit tests
- Loading branch information
Showing
11 changed files
with
121 additions
and
19 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"statusCode": 200, | ||
"headers": { | ||
"Date": "Mon, 18 Mar 2024 07:23:21 GMT", | ||
"Content-Type": "application\/json; charset=utf-8", | ||
"Content-Length": "349", | ||
"Connection": "keep-alive", | ||
"Cache-Control": "no-cache", | ||
"Pragma": "no-cache", | ||
"Expires": "-1", | ||
"X-AspNet-Version": "4.0.30319", | ||
"X-Powered-By": "ASP.NET", | ||
"CF-Cache-Status": "DYNAMIC", | ||
"Set-Cookie": "__cf_bm=TGl7fKsZWrlcSpSdAkNNFYfdkns8Jlrb6D.Jbfryb4Q-1710746601-1.0.1.1-CJX4cWrhy_pPn_jbXUylfd2x5YnjeCK6_yvtfUcsfUgVqEhnxXeu0IKPD_JkfBjtiYM2.OaQj9dJh1omCTNjyA; path=\/; expires=Mon, 18-Mar-24 07:53:21 GMT; domain=.pesapal.com; HttpOnly; Secure; SameSite=None", | ||
"Server": "cloudflare", | ||
"CF-RAY": "86637a13692ab199-NBO" | ||
}, | ||
"data": "{\"id\":4254,\"url\":\"http:\/\/kihn.biz\/repellat-voluptatem-officiis-reiciendis-facere-blanditiis-quia-accusantium.html\",\"created_date\":\"2024-03-18T07:23:21.6391704Z\",\"ipn_id\":\"0fb0514f-da8c-43e4-b841-dd759364c16b\",\"notification_type\":0,\"ipn_notification_type_description\":\"GET\",\"ipn_status\":1,\"ipn_status_decription\":\"Active\",\"error\":null,\"status\":\"200\"}" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"statusCode": 200, | ||
"headers": { | ||
"Date": "Mon, 18 Mar 2024 07:23:21 GMT", | ||
"Content-Type": "application\/json; charset=utf-8", | ||
"Content-Length": "564", | ||
"Connection": "keep-alive", | ||
"Cache-Control": "no-cache", | ||
"Pragma": "no-cache", | ||
"Expires": "-1", | ||
"X-AspNet-Version": "4.0.30319", | ||
"X-Powered-By": "ASP.NET", | ||
"CF-Cache-Status": "DYNAMIC", | ||
"Set-Cookie": "__cf_bm=JjT4WUkvuEe_I.db7.GYNJ4Zk9Xxu9SUQ9rihKy0l4M-1710746601-1.0.1.1-.E9pYm_AbCJa3dAetg0CYha5v9kzpGSqYICO.Nf612g5PNab0YEhEzLHNvpLghpbhnA9vaSvVPjHB7IfDUXDGw; path=\/; expires=Mon, 18-Mar-24 07:53:21 GMT; domain=.pesapal.com; HttpOnly; Secure; SameSite=None", | ||
"Server": "cloudflare", | ||
"CF-RAY": "86637a103aa3b196-NBO" | ||
}, | ||
"data": "{\"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3VzZXJkYXRhIjoiZWQ2MTkwMGYtZGNiMy00NjM2LWIxNGUtY2U1MGQwYzk2M2I1IiwidWlkIjoicWtpbzFCR0dZQVhUdTJKT2ZtN1hTWE5ydW9ac3JxRVciLCJuYmYiOjE3MTA3NDY2MDEsImV4cCI6MTcxMDc1MDIwMSwiaWF0IjoxNzEwNzQ2NjAxLCJpc3MiOiJodHRwOi8vY3licWEucGVzYXBhbC5jb20vIiwiYXVkIjoiaHR0cDovL2N5YnFhLnBlc2FwYWwuY29tLyJ9.Ygrl0JshPpelP_sIK_fRy41ctNKNWtvV0ZuCsPMxvqI\",\"expiryDate\":\"2024-03-18T08:23:21.1688946Z\",\"error\":null,\"status\":\"200\",\"message\":\"Request processed successfully\"}" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"statusCode": 200, | ||
"headers": { | ||
"Date": "Mon, 18 Mar 2024 07:23:22 GMT", | ||
"Content-Type": "application\/json; charset=utf-8", | ||
"Content-Length": "2", | ||
"Connection": "keep-alive", | ||
"Cache-Control": "no-cache", | ||
"Pragma": "no-cache", | ||
"Expires": "-1", | ||
"X-AspNet-Version": "4.0.30319", | ||
"X-Powered-By": "ASP.NET", | ||
"CF-Cache-Status": "DYNAMIC", | ||
"Set-Cookie": "__cf_bm=ZQbkCCHgyCncNSiUyxpscONmuptjuJ3DVe2Dd6wBPXs-1710746602-1.0.1.1-u2nKN5GlFMJQg6dJxSr4WDA9K0gF7_Th28T3n7IIln..gltmiBkiHdg8tAwitfc5oMG74SFYfQFEpEg9sDcO5w; path=\/; expires=Mon, 18-Mar-24 07:53:22 GMT; domain=.pesapal.com; HttpOnly; Secure; SameSite=None", | ||
"Server": "cloudflare", | ||
"CF-RAY": "86637a16587e1b5f-NBO" | ||
}, | ||
"data": "[]" | ||
} |
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,5 +1,22 @@ | ||
<?php | ||
|
||
use NjoguAmos\Pesapal\Requests\CreatePesapalIpn; | ||
use NjoguAmos\Pesapal\Requests\CreatePesapalToken; | ||
use NjoguAmos\Pesapal\Requests\GetPesapalIpns; | ||
use NjoguAmos\Pesapal\Tests\TestCase; | ||
use Saloon\Http\Faking\MockClient; | ||
use Saloon\Http\Faking\MockResponse; | ||
use Saloon\MockConfig; | ||
use Saloon\Config; | ||
|
||
uses(TestCase::class)->in(__DIR__); | ||
|
||
|
||
MockConfig::setFixturePath('tests/Fixtures'); | ||
Config::preventStrayRequests(); | ||
|
||
MockClient::global(mockData: [ | ||
CreatePesapalToken::class => MockResponse::fixture(name: 'CreatePesapalToken'), | ||
CreatePesapalIpn::class => MockResponse::fixture(name: 'CreatePesapalIpn'), | ||
GetPesapalIpns::class => MockResponse::fixture(name: 'GetPesapalIpns'), | ||
]); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
use NjoguAmos\Pesapal\Enums\IpnType; | ||
use NjoguAmos\Pesapal\Requests\CreatePesapalIpn; | ||
|
||
it(description: 'returns correct endpoint', closure: function () { | ||
$request = new CreatePesapalIpn(url: fake()->url, ipnType: IpnType::GET); | ||
|
||
expect(value: $request->resolveEndpoint())->toBe(expected: '/api/URLSetup/RegisterIPN'); | ||
}); | ||
|
||
it(description: 'forms the correct request body', closure: function () { | ||
$url = fake()->url; | ||
|
||
$request = new CreatePesapalIpn(url: $url, ipnType: IpnType::GET); | ||
|
||
expect(value: $request->body()->get(key: 'url'))->toBe(expected: $url) | ||
->and(value: $request->body()->get(key: 'ipn_notification_type'))->toBe(expected: IpnType::GET->name); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use NjoguAmos\Pesapal\Requests\GetPesapalIpns; | ||
|
||
it(description: 'returns correct endpoint', closure: function () { | ||
$request = new GetPesapalIpns(); | ||
|
||
expect(value: $request->resolveEndpoint())->toBe(expected: '/api/URLSetup/GetIpnList'); | ||
}); |