diff --git a/docs/ApplePay.md b/docs/ApplePay.md index 5805e69..6d661b5 100644 --- a/docs/ApplePay.md +++ b/docs/ApplePay.md @@ -74,4 +74,5 @@ try { // Handle specific errors, e.g., domain not found, invalid operation. } -?> \ No newline at end of file +?> +``` \ No newline at end of file diff --git a/docs/BulkCharge.md b/docs/BulkCharge.md index 8628559..fcd0d24 100644 --- a/docs/BulkCharge.md +++ b/docs/BulkCharge.md @@ -119,4 +119,4 @@ if ($batchCode) { echo "\nSkipping batch-specific operations as no valid batch code was obtained from initiation.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Charge.md b/docs/Charge.md index a579100..9b97040 100644 --- a/docs/Charge.md +++ b/docs/Charge.md @@ -163,4 +163,4 @@ try { // 2. You extract the reference from the initial response. // 3. You call the respective submit method with the user-provided data and the reference. -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Customer.md b/docs/Customer.md index 2b5c50f..5d22495 100644 --- a/docs/Customer.md +++ b/docs/Customer.md @@ -149,4 +149,4 @@ try { echo "Error deactivating authorization '{$sampleAuthorizationCode}': " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Dispute.md b/docs/Dispute.md index 61f5196..3490cdd 100644 --- a/docs/Dispute.md +++ b/docs/Dispute.md @@ -161,4 +161,4 @@ try { echo "Error exporting disputes: " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Integration.md b/docs/Integration.md index 9d76478..2ebce31 100644 --- a/docs/Integration.md +++ b/docs/Integration.md @@ -65,4 +65,4 @@ try { echo "Error verifying updated payment session timeout: " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Miscellaneous.md b/docs/Miscellaneous.md index 006646d..0a33075 100644 --- a/docs/Miscellaneous.md +++ b/docs/Miscellaneous.md @@ -86,4 +86,4 @@ try { echo "Error fetching Nigerian states: " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/PaymentPage.md b/docs/PaymentPage.md index 36a486b..367fbbf 100644 --- a/docs/PaymentPage.md +++ b/docs/PaymentPage.md @@ -166,4 +166,4 @@ if ($fixedPageId && $dummyProductId) { echo "\nSkipping addProduct operation as either page ID or dummy product ID is missing.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/PaymentRequest.md b/docs/PaymentRequest.md index 98f6c34..503c77e 100644 --- a/docs/PaymentRequest.md +++ b/docs/PaymentRequest.md @@ -140,4 +140,4 @@ try { echo "Error fetching total payment requests: " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Plan.md b/docs/Plan.md index 558df46..8e8d3f8 100644 --- a/docs/Plan.md +++ b/docs/Plan.md @@ -102,4 +102,4 @@ if ($planId || $planCode) { echo "\nSkipping plan-specific operations as no valid plan ID/code was obtained from creation.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Product.md b/docs/Product.md index 0afca76..99adfa3 100644 --- a/docs/Product.md +++ b/docs/Product.md @@ -106,4 +106,4 @@ if ($productId) { echo "\nSkipping product-specific operations as no valid product ID was obtained from creation.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Refund.md b/docs/Refund.md index f99004a..a221c78 100644 --- a/docs/Refund.md +++ b/docs/Refund.md @@ -92,4 +92,4 @@ if ($refundId) { echo "\nSkipping fetch refund operation as no valid refund ID was obtained from creation.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Settlement.md b/docs/Settlement.md index 65954bc..de5e060 100644 --- a/docs/Settlement.md +++ b/docs/Settlement.md @@ -69,4 +69,4 @@ if ($sampleSettlementId) { echo "\nSkipping fetching settlement transactions as no valid settlement ID was available.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/SubAccount.md b/docs/SubAccount.md index a613314..79a2f74 100644 --- a/docs/SubAccount.md +++ b/docs/SubAccount.md @@ -93,4 +93,4 @@ if ($subaccountId || $subaccountCode) { echo "\nSkipping subaccount-specific operations as no valid subaccount ID/code was obtained from creation.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Subscription.md b/docs/Subscription.md index 3a337c4..53b30bc 100644 --- a/docs/Subscription.md +++ b/docs/Subscription.md @@ -138,4 +138,4 @@ if ($subscriptionCode && $emailToken) { echo "\nSkipping subscription-specific operations as no valid subscription code/token was obtained.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Terminal.md b/docs/Terminal.md index 9605fa2..4c83f9d 100644 --- a/docs/Terminal.md +++ b/docs/Terminal.md @@ -159,4 +159,4 @@ if ($commissionedTerminalId && $newTerminalSerialNumber) { // Only decommission echo "\nSkipping decommission operation as no new terminal was commissioned in this run.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Transaction.md b/docs/Transaction.md index 93830ae..ae5a22f 100644 --- a/docs/Transaction.md +++ b/docs/Transaction.md @@ -207,4 +207,4 @@ if ($authorizationCode && $sampleCustomerEmail) { echo "\nSkipping partial debit as no valid authorization code or customer email is available.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/TransactionSplit.md b/docs/TransactionSplit.md index 39f6035..9a37965 100644 --- a/docs/TransactionSplit.md +++ b/docs/TransactionSplit.md @@ -143,4 +143,4 @@ if ($splitId || $splitCode) { echo "\nSkipping split-specific operations as no valid split ID/code was obtained from creation.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Transfer.md b/docs/Transfer.md index 5a2af42..0ad8e1c 100644 --- a/docs/Transfer.md +++ b/docs/Transfer.md @@ -145,4 +145,4 @@ if ($transferCode) { echo "\nSkipping transfer-specific operations as no valid transfer code is available.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/TransferControl.md b/docs/TransferControl.md index f36a939..4201c94 100644 --- a/docs/TransferControl.md +++ b/docs/TransferControl.md @@ -116,4 +116,4 @@ try { echo "Error enabling OTP: " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/TransferRecipient.md b/docs/TransferRecipient.md index 68b0a5a..3145f50 100644 --- a/docs/TransferRecipient.md +++ b/docs/TransferRecipient.md @@ -135,4 +135,4 @@ if ($recipientId || $recipientCode) { echo "\nSkipping recipient-specific operations as no valid recipient ID/code was obtained.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/Verification.md b/docs/Verification.md index 1000ee9..2ab35b7 100644 --- a/docs/Verification.md +++ b/docs/Verification.md @@ -81,4 +81,4 @@ try { echo "Error resolving card BIN: " . $e->getMessage() . "\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/docs/VirtualAccount.md b/docs/VirtualAccount.md index a8d4497..8180329 100644 --- a/docs/VirtualAccount.md +++ b/docs/VirtualAccount.md @@ -170,4 +170,4 @@ if ($virtualAccountId && $virtualAccountNumber && $virtualAccountBankSlug) { echo "\nSkipping virtual account-specific operations as no valid virtual account ID/number/bank slug was obtained.\n"; } -?> \ No newline at end of file +?>``` \ No newline at end of file diff --git a/tests/Factory.php b/tests/Factory.php new file mode 100644 index 0000000..48e0224 --- /dev/null +++ b/tests/Factory.php @@ -0,0 +1,37 @@ +withSecretKey('sk_test_123')->make(); + + expect($client)->toBeInstanceOf(Client::class); +}); + +it('can create a client with a public key', function () { + $client = (new Factory())->withPublicKey('pk_test_123')->make(); + + expect($client)->toBeInstanceOf(Client::class); +}); + +it('can create a client with a base URI', function () { + $client = (new Factory())->withBaseUri('https://example.com')->make(); + + expect($client)->toBeInstanceOf(Client::class); +}); + +it('can create a client with a custom HTTP client', function () { + $httpClient = Mockery::mock(ClientInterface::class); + + $client = (new Factory())->withHttpClient($httpClient)->make(); + + expect($client)->toBeInstanceOf(Client::class); +}); + +it('can create a client with a custom HTTP header', function () { + $client = (new Factory())->withHttpHeader('X-Custom', 'value')->make(); + + expect($client)->toBeInstanceOf(Client::class); +}); diff --git a/tests/Paystack.php b/tests/Paystack.php index 0aaf2c3..9b092ed 100644 --- a/tests/Paystack.php +++ b/tests/Paystack.php @@ -5,6 +5,31 @@ use MusheAbdulHakim\Paystack\Factory; use MusheAbdulHakim\Paystack\Paystack; +it('can initialize the client factory', function () { + $factory = Paystack::init('secret'); + expect($factory)->toBeInstanceOf(Factory::class); +}); + +it('can create a client with secret key', function () { + $client = Paystack::client('secret'); + expect($client)->toBeInstanceOf(Client::class); +}); + +it('can create a client with secret key and base uri', function () { + $client = Paystack::client('secret', 'https://example.com'); + expect($client)->toBeInstanceOf(Client::class); +}); + +it('can create a new factory instance', function () { + $factory = Paystack::factory(); + expect($factory)->toBeInstanceOf(Factory::class); +}); + +it('should return a Factory instance when calling init', function () { + $factory = Paystack::init('test_secret'); + expect($factory)->toBeInstanceOf(Factory::class); +}); + it('may create client', function () { $paystack = Paystack::client('key'); expect($paystack)->toBeInstanceOf(Client::class);