|
5 | 5 | use GuzzleHttp\Exception\ClientException; |
6 | 6 | use GuzzleHttp\Exception\GuzzleException; |
7 | 7 | use Lloricode\Paymaya\DataTransferObjects\Checkout\Customization\CustomizationDto; |
8 | | -use Lloricode\Paymaya\Requests\Customization\DeleteCustomizationRequest; |
9 | 8 | use Lloricode\Paymaya\Requests\Customization\RegisterCustomizationRequest; |
10 | | -use Lloricode\Paymaya\Requests\Customization\RetrieveCustomizationRequest; |
11 | 9 | use Saloon\Http\Faking\MockClient; |
12 | 10 | use Saloon\Http\Faking\MockResponse; |
13 | 11 |
|
14 | | -use function PHPUnit\Framework\assertEquals; |
15 | 12 | use function PHPUnit\Framework\assertSame; |
16 | 13 |
|
17 | 14 | beforeEach(function () { |
|
61 | 58 | json_encode($response->toArray(), JSON_PRETTY_PRINT) |
62 | 59 | ); |
63 | 60 | }); |
64 | | - |
65 | | -it('retrieve', function () { |
66 | | - $data = '{ |
67 | | - "logoUrl": "https://image-logo.png", |
68 | | - "iconUrl": "https://image-icon.png", |
69 | | - "appleTouchIconUrl": "https://image-apple.png", |
70 | | - "customTitle": "Test Title Mock", |
71 | | - "colorScheme": "#e01c44", |
72 | | - "redirectTimer": 3, |
73 | | - "hideReceiptInput": true, |
74 | | - "skipResultPage": false, |
75 | | - "showMerchantName": true |
76 | | -}'; |
77 | | - |
78 | | - MockClient::global([ |
79 | | - RetrieveCustomizationRequest::class => MockResponse::make( |
80 | | - body: $data, |
81 | | - ), |
82 | | - ]); |
83 | | - |
84 | | - $response = (new RetrieveCustomizationRequest) |
85 | | - ->send() |
86 | | - ->dto(); |
87 | | - |
88 | | - assertSame( |
89 | | - json_encode(json_decode($data), JSON_PRETTY_PRINT), |
90 | | - json_encode($response->toArray(), JSON_PRETTY_PRINT) |
91 | | - ); |
92 | | -}); |
93 | | - |
94 | | -it('retrieve no data', function () { |
95 | | - MockClient::global([ |
96 | | - RetrieveCustomizationRequest::class => MockResponse::make( |
97 | | - status: 404, |
98 | | - ), |
99 | | - ]); |
100 | | - |
101 | | - $response = (new RetrieveCustomizationRequest) |
102 | | - ->send() |
103 | | - ->dto(); |
104 | | - |
105 | | - assertSame( |
106 | | - json_encode(json_decode(json_encode(new CustomizationDto)), JSON_PRETTY_PRINT), |
107 | | - json_encode($response->toArray(), JSON_PRETTY_PRINT) |
108 | | - ); |
109 | | -})->todo('handle 404'); |
110 | | - |
111 | | -it('delete data', function () { |
112 | | - $mockClient = MockClient::global([ |
113 | | - DeleteCustomizationRequest::class => MockResponse::make( |
114 | | - status: 204, |
115 | | - ), |
116 | | - ]); |
117 | | - |
118 | | - $response = (new DeleteCustomizationRequest) |
119 | | - ->send(); |
120 | | - |
121 | | - $mockClient->assertSentCount(1); |
122 | | - assertEquals(204, $response->status()); |
123 | | -}); |
0 commit comments