1 | <?php |
||||||
2 | |||||||
3 | /* |
||||||
4 | * This file has been created by developers from BitBag. |
||||||
5 | * Feel free to contact us once you face any issues or want to start |
||||||
6 | * another great project. |
||||||
7 | * You can find more information about us on https://bitbag.shop and write us |
||||||
8 | * an email on [email protected]. |
||||||
9 | */ |
||||||
10 | |||||||
11 | declare(strict_types=1); |
||||||
12 | |||||||
13 | namespace spec\BitBag\SyliusQuadPayPlugin\Client; |
||||||
14 | |||||||
15 | use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClient; |
||||||
16 | use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClientInterface; |
||||||
17 | use GuzzleHttp\ClientInterface; |
||||||
18 | use PhpSpec\ObjectBehavior; |
||||||
19 | use Psr\Http\Message\ResponseInterface; |
||||||
20 | |||||||
21 | final class QuadPayApiClientSpec extends ObjectBehavior |
||||||
22 | { |
||||||
23 | function let(ClientInterface $client): void |
||||||
0 ignored issues
–
show
|
|||||||
24 | { |
||||||
25 | $this->beConstructedWith($client); |
||||||
26 | |||||||
27 | $this->setConfig( |
||||||
0 ignored issues
–
show
The method
setConfig() does not exist on spec\BitBag\SyliusQuadPa...nt\QuadPayApiClientSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
28 | 'test', |
||||||
29 | 'test', |
||||||
30 | 'https://api-ci.quadpay.com/', |
||||||
31 | 'https://api-ci.quadpay.com/', |
||||||
32 | 'https://api-ci.quadpay.com/' |
||||||
33 | ); |
||||||
34 | } |
||||||
35 | |||||||
36 | function it_is_initializable(): void |
||||||
0 ignored issues
–
show
|
|||||||
37 | { |
||||||
38 | $this->shouldHaveType(QuadPayApiClient::class); |
||||||
39 | } |
||||||
40 | |||||||
41 | function it_implements_quadpay_api_client_interface(): void |
||||||
42 | { |
||||||
43 | $this->shouldHaveType(QuadPayApiClientInterface::class); |
||||||
44 | } |
||||||
45 | |||||||
46 | function it_creates_order(ClientInterface $client, ResponseInterface $tokenResponse, ResponseInterface $orderResponse): void |
||||||
47 | { |
||||||
48 | $tokenResponse->getBody()->willReturn('{ |
||||||
0 ignored issues
–
show
The method
willReturn() does not exist on Psr\Http\Message\StreamInterface . It seems like you code against a sub-type of Psr\Http\Message\StreamInterface such as GuzzleHttp\Psr7\InflateStream or GuzzleHttp\Psr7\LazyOpenStream or GuzzleHttp\Psr7\MultipartStream or GuzzleHttp\Psr7\DroppingStream or GuzzleHttp\Psr7\NoSeekStream or GuzzleHttp\Psr7\LimitStream or GuzzleHttp\Psr7\CachingStream .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
49 | "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciO", |
||||||
50 | "expires_in": 86400, |
||||||
51 | "scope": "read:me merchant", |
||||||
52 | "token_type": "Bearer" |
||||||
53 | }'); |
||||||
54 | |||||||
55 | $orderResponse->getBody()->willReturn('{"orderId": "test"}'); |
||||||
56 | |||||||
57 | $client->request( |
||||||
58 | 'POST', |
||||||
59 | 'https://api-ci.quadpay.com/oauth/token', |
||||||
60 | [ |
||||||
61 | 'json' => [ |
||||||
62 | 'client_id' => 'test', |
||||||
63 | 'client_secret' => 'test', |
||||||
64 | 'audience' => 'https://api-ci.quadpay.com/', |
||||||
65 | 'grant_type' => 'client_credentials', |
||||||
66 | ], |
||||||
67 | 'headers' => [ |
||||||
68 | 'Content-Type' => 'application/json', |
||||||
69 | ], |
||||||
70 | ] |
||||||
71 | )->willReturn($tokenResponse); |
||||||
0 ignored issues
–
show
The method
willReturn() does not exist on Psr\Http\Message\ResponseInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
72 | |||||||
73 | $client->request( |
||||||
74 | 'POST', |
||||||
75 | 'https://api-ci.quadpay.com/order', |
||||||
76 | [ |
||||||
77 | 'json' => [ |
||||||
78 | 'test' => 'test', |
||||||
79 | ], |
||||||
80 | 'headers' => [ |
||||||
81 | 'Content-Type' => 'application/json', |
||||||
82 | 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciO', |
||||||
83 | ], |
||||||
84 | ] |
||||||
85 | )->willReturn($orderResponse); |
||||||
86 | |||||||
87 | $this->createOrder(['test' => 'test'])->shouldReturn(['orderId' => 'test']); |
||||||
0 ignored issues
–
show
The method
createOrder() does not exist on spec\BitBag\SyliusQuadPa...nt\QuadPayApiClientSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
88 | } |
||||||
89 | |||||||
90 | function it_gets_order_by_id(ClientInterface $client, ResponseInterface $tokenResponse, ResponseInterface $orderResponse): void |
||||||
91 | { |
||||||
92 | $tokenResponse->getBody()->willReturn('{ |
||||||
93 | "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciO", |
||||||
94 | "expires_in": 86400, |
||||||
95 | "scope": "read:me merchant", |
||||||
96 | "token_type": "Bearer" |
||||||
97 | }'); |
||||||
98 | |||||||
99 | $client->request( |
||||||
100 | 'POST', |
||||||
101 | 'https://api-ci.quadpay.com/oauth/token', |
||||||
102 | [ |
||||||
103 | 'json' => [ |
||||||
104 | 'client_id' => 'test', |
||||||
105 | 'client_secret' => 'test', |
||||||
106 | 'audience' => 'https://api-ci.quadpay.com/', |
||||||
107 | 'grant_type' => 'client_credentials', |
||||||
108 | ], |
||||||
109 | 'headers' => [ |
||||||
110 | 'Content-Type' => 'application/json', |
||||||
111 | ], |
||||||
112 | ] |
||||||
113 | )->willReturn($tokenResponse); |
||||||
114 | |||||||
115 | $orderResponse->getBody()->willReturn('{"orderId": "h4897t4htye8iype"}'); |
||||||
116 | |||||||
117 | $client->request( |
||||||
118 | 'GET', |
||||||
119 | 'https://api-ci.quadpay.com/order/h4897t4htye8iype', |
||||||
120 | [ |
||||||
121 | 'json' => [], |
||||||
122 | 'headers' => [ |
||||||
123 | 'Content-Type' => 'application/json', |
||||||
124 | 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciO', |
||||||
125 | ], |
||||||
126 | ] |
||||||
127 | )->willReturn($orderResponse); |
||||||
128 | |||||||
129 | $this->getOrderById('h4897t4htye8iype')->shouldReturn(['orderId' => 'h4897t4htye8iype']); |
||||||
0 ignored issues
–
show
The method
getOrderById() does not exist on spec\BitBag\SyliusQuadPa...nt\QuadPayApiClientSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
130 | } |
||||||
131 | |||||||
132 | function it_gets_order_by_token(ClientInterface $client, ResponseInterface $tokenResponse, ResponseInterface $orderResponse): void |
||||||
133 | { |
||||||
134 | $tokenResponse->getBody()->willReturn('{ |
||||||
135 | "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciO", |
||||||
136 | "expires_in": 86400, |
||||||
137 | "scope": "read:me merchant", |
||||||
138 | "token_type": "Bearer" |
||||||
139 | }'); |
||||||
140 | |||||||
141 | $client->request( |
||||||
142 | 'POST', |
||||||
143 | 'https://api-ci.quadpay.com/oauth/token', |
||||||
144 | [ |
||||||
145 | 'json' => [ |
||||||
146 | 'client_id' => 'test', |
||||||
147 | 'client_secret' => 'test', |
||||||
148 | 'audience' => 'https://api-ci.quadpay.com/', |
||||||
149 | 'grant_type' => 'client_credentials', |
||||||
150 | ], |
||||||
151 | 'headers' => [ |
||||||
152 | 'Content-Type' => 'application/json', |
||||||
153 | ], |
||||||
154 | ] |
||||||
155 | )->willReturn($tokenResponse); |
||||||
156 | |||||||
157 | $orderResponse->getBody()->willReturn('{"orderId": "h4897t4htye8iype"}'); |
||||||
158 | |||||||
159 | $client->request( |
||||||
160 | 'GET', |
||||||
161 | 'https://api-ci.quadpay.com/order?token=h4897t4htye8iype', |
||||||
162 | [ |
||||||
163 | 'json' => [], |
||||||
164 | 'headers' => [ |
||||||
165 | 'Content-Type' => 'application/json', |
||||||
166 | 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciO', |
||||||
167 | ], |
||||||
168 | ] |
||||||
169 | )->willReturn($orderResponse); |
||||||
170 | |||||||
171 | $this->getOrderByToken('h4897t4htye8iype')->shouldReturn(['orderId' => 'h4897t4htye8iype']); |
||||||
0 ignored issues
–
show
The method
getOrderByToken() does not exist on spec\BitBag\SyliusQuadPa...nt\QuadPayApiClientSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
172 | } |
||||||
173 | |||||||
174 | function it_refunds( |
||||||
175 | ClientInterface $client, |
||||||
176 | ResponseInterface $tokenResponse, |
||||||
177 | ResponseInterface $orderResponse, |
||||||
178 | ResponseInterface $refundResponse |
||||||
179 | ): void { |
||||||
180 | $tokenResponse->getBody()->willReturn('{ |
||||||
181 | "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciO", |
||||||
182 | "expires_in": 86400, |
||||||
183 | "scope": "read:me merchant", |
||||||
184 | "token_type": "Bearer" |
||||||
185 | }'); |
||||||
186 | |||||||
187 | $client->request( |
||||||
188 | 'POST', |
||||||
189 | 'https://api-ci.quadpay.com/oauth/token', |
||||||
190 | [ |
||||||
191 | 'json' => [ |
||||||
192 | 'client_id' => 'test', |
||||||
193 | 'client_secret' => 'test', |
||||||
194 | 'audience' => 'https://api-ci.quadpay.com/', |
||||||
195 | 'grant_type' => 'client_credentials', |
||||||
196 | ], |
||||||
197 | 'headers' => [ |
||||||
198 | 'Content-Type' => 'application/json', |
||||||
199 | ], |
||||||
200 | ] |
||||||
201 | )->willReturn($tokenResponse); |
||||||
202 | |||||||
203 | $orderResponse->getBody()->willReturn('{"orderId": "h4897t4htye8iype"}'); |
||||||
204 | |||||||
205 | $client->request( |
||||||
206 | 'GET', |
||||||
207 | 'https://api-ci.quadpay.com/order?token=gf74yr4iuyti4hjtikht', |
||||||
208 | [ |
||||||
209 | 'json' => [], |
||||||
210 | 'headers' => [ |
||||||
211 | 'Content-Type' => 'application/json', |
||||||
212 | 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciO', |
||||||
213 | ], |
||||||
214 | ] |
||||||
215 | )->willReturn($orderResponse); |
||||||
216 | |||||||
217 | $refundResponse->getBody()->willReturn('{"refundId": "test"}'); |
||||||
218 | |||||||
219 | $client->request( |
||||||
220 | 'POST', |
||||||
221 | 'https://api-ci.quadpay.com/order/h4897t4htye8iype/refund', |
||||||
222 | [ |
||||||
223 | 'json' => [ |
||||||
224 | 'amount' => 20.77, |
||||||
225 | 'merchantRefundReference' => 'hfeirjtlegjktejio', |
||||||
226 | ], |
||||||
227 | 'headers' => [ |
||||||
228 | 'Content-Type' => 'application/json', |
||||||
229 | 'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciO', |
||||||
230 | ], |
||||||
231 | ] |
||||||
232 | )->willReturn($refundResponse); |
||||||
233 | |||||||
234 | $this->refund(20.77, 'hfeirjtlegjktejio', 'gf74yr4iuyti4hjtikht')->shouldReturn([ |
||||||
0 ignored issues
–
show
The method
refund() does not exist on spec\BitBag\SyliusQuadPa...nt\QuadPayApiClientSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
235 | 'refundId' => 'test', |
||||||
236 | ]); |
||||||
237 | } |
||||||
238 | } |
||||||
239 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.