Skip to content

Commit 35c08bd

Browse files
more test cases added
1 parent b53aa89 commit 35c08bd

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

tests/Factory.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use MusheAbdulHakim\Paystack\Client;
4+
use MusheAbdulHakim\Paystack\Factory;
5+
use Psr\Http\Client\ClientInterface;
6+
7+
it('can create a client with a secret key', function () {
8+
$client = (new Factory())->withSecretKey('sk_test_123')->make();
9+
10+
expect($client)->toBeInstanceOf(Client::class);
11+
});
12+
13+
it('can create a client with a public key', function () {
14+
$client = (new Factory())->withPublicKey('pk_test_123')->make();
15+
16+
expect($client)->toBeInstanceOf(Client::class);
17+
});
18+
19+
it('can create a client with a base URI', function () {
20+
$client = (new Factory())->withBaseUri('https://example.com')->make();
21+
22+
expect($client)->toBeInstanceOf(Client::class);
23+
});
24+
25+
it('can create a client with a custom HTTP client', function () {
26+
$httpClient = Mockery::mock(ClientInterface::class);
27+
28+
$client = (new Factory())->withHttpClient($httpClient)->make();
29+
30+
expect($client)->toBeInstanceOf(Client::class);
31+
});
32+
33+
it('can create a client with a custom HTTP header', function () {
34+
$client = (new Factory())->withHttpHeader('X-Custom', 'value')->make();
35+
36+
expect($client)->toBeInstanceOf(Client::class);
37+
});

tests/Paystack.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,31 @@
55
use MusheAbdulHakim\Paystack\Factory;
66
use MusheAbdulHakim\Paystack\Paystack;
77

8+
it('can initialize the client factory', function () {
9+
$factory = Paystack::init('secret');
10+
expect($factory)->toBeInstanceOf(Factory::class);
11+
});
12+
13+
it('can create a client with secret key', function () {
14+
$client = Paystack::client('secret');
15+
expect($client)->toBeInstanceOf(Client::class);
16+
});
17+
18+
it('can create a client with secret key and base uri', function () {
19+
$client = Paystack::client('secret', 'https://example.com');
20+
expect($client)->toBeInstanceOf(Client::class);
21+
});
22+
23+
it('can create a new factory instance', function () {
24+
$factory = Paystack::factory();
25+
expect($factory)->toBeInstanceOf(Factory::class);
26+
});
27+
28+
it('should return a Factory instance when calling init', function () {
29+
$factory = Paystack::init('test_secret');
30+
expect($factory)->toBeInstanceOf(Factory::class);
31+
});
32+
833
it('may create client', function () {
934
$paystack = Paystack::client('key');
1035
expect($paystack)->toBeInstanceOf(Client::class);

0 commit comments

Comments
 (0)