Skip to content

Commit

Permalink
checkout test
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdrakedennis committed Mar 31, 2023
1 parent 25babb8 commit eba0d45
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"laravel-tebex-checkout"
],
"homepage": "https://github.com/useshimmer/laravel-tebex-checkout",
"license": "MIT",
"license": "GPLv3",
"authors": [
{
"name": "Robert Dennis",
Expand Down
38 changes: 38 additions & 0 deletions tests/CheckoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;
use Shimmer\LaravelTebexCheckout\Requests\Checkout\CreateCheckoutRequest;
use Shimmer\LaravelTebexCheckout\TebexCheckout;

it('successfully creates a checkout request', function () {
$mockClient = new MockClient([
CreateCheckoutRequest::class => MockResponse::fixture('create.checkout.request')
]);

$checkout = new TebexCheckout('foo', 'bar');
$checkout->withMockClient($mockClient);

$request = new CreateCheckoutRequest(
basket: [
'return_url' => 'http://foo.com',
'complete_url' => 'http://bar.com',
'custom' => [
'baz' => 'buzz'
]
],
items: [
[
'package' => [
'name' => 'foobar',
'price' => 12.34
]
]
]
);

$response = $checkout->send($request);

expect($response->successful())->toBeTrue();
expect($response->json())->toHaveKey('price', 12.34);
});
5 changes: 0 additions & 5 deletions tests/ExampleTest.php

This file was deleted.

1 change: 1 addition & 0 deletions tests/Fixtures/Saloon/create.checkout.request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"statusCode":200,"headers":{"Date":"Fri, 31 Mar 2023 00:09:25 GMT","Content-Type":"application\/json","Transfer-Encoding":"chunked","Connection":"keep-alive","CF-Ray":"fake-EWR","Cache-Control":"no-cache, private","Strict-Transport-Security":"max-age=31536000;","CF-Cache-Status":"DYNAMIC","TB-Node":"fake","X-Frame-Options":"SAMEORIGIN","X-VAT-Mode":"exclusive","Set-Cookie":"fake; path=\/; expires=Fri, 31-Mar-23 00:39:25 GMT; domain=.tebex.io; HttpOnly; Secure; SameSite=None","Server":"cloudflare"},"data":"{\"ident\":\"bgew6k-e5479e0f75f302b23947defa7219256a00055e75\",\"expire\":\"2023-04-05 00:09:25\",\"price\":12.34,\"priceDetails\":{\"fullPrice\":12.34,\"subTotal\":12.34,\"discounts\":[],\"total\":12.34,\"surcharges\":[],\"tax\":0,\"balance\":12.34,\"sales\":[],\"giftcards\":[],\"recurring\":null,\"roundUp\":null},\"type\":\"single\",\"recurring\":false,\"recurringPeriod\":null,\"complete\":false,\"tax\":null,\"username\":null,\"discounts\":null,\"coupons\":[],\"giftcards\":[],\"address\":{\"name\":null,\"first_name\":null,\"last_name\":null,\"address\":null,\"email\":null,\"state_id\":null,\"country\":\"XX\",\"postal_code\":null},\"actions\":null,\"game_currency\":null,\"tebex_account_id\":null,\"verified\":null,\"rows\":[{\"id\":151356931,\"basket\":692696684,\"package\":null,\"override\":0,\"quantity\":1,\"server\":null,\"price\":12.34,\"gift_username_id\":null,\"options\":null,\"meta\":{\"name\":\"foobar\",\"rowprice\":12.34,\"initialprice\":12.34,\"isCumulative\":false,\"requiredPackages\":[],\"requiresAny\":false,\"category\":false,\"producesGiftCard\":false,\"allowsGiftCards\":true,\"servers\":[],\"limits\":{\"user\":{\"enabled\":false,\"timestamp\":0,\"limit\":false},\"global\":{\"enabled\":false,\"timestamp\":0,\"limit\":false},\"packageExpiryTime\":0},\"hasDeliverables\":false,\"hasSellerProtection\":true,\"itemType\":null,\"revenue_share\":[],\"realprice\":12.34},\"custom\":null}],\"fingerprint\":null,\"creator_code\":\"\",\"roundup\":null,\"custom\":{\"baz\":\"buzz\"},\"links\":{\"checkout\":\"https:\\\/\\\/checkout.tebex.io\\\/checkout\\\/fake\"}}"}

0 comments on commit eba0d45

Please sign in to comment.