2
2
3
3
namespace spec \Http \Client \Plugin ;
4
4
5
- use Http \Client \Utils \Promise \FulfilledPromise ;
6
5
use Http \Client \Plugin \RedirectPlugin ;
7
- use Http \Client \Promise ;
6
+ use Http \Client \Tools \Promise \FulfilledPromise ;
7
+ use Http \Promise \Promise ;
8
8
use Psr \Http \Message \RequestInterface ;
9
9
use Psr \Http \Message \ResponseInterface ;
10
10
use Psr \Http \Message \UriInterface ;
@@ -59,13 +59,12 @@ function it_redirects_on_302(
59
59
}
60
60
};
61
61
62
- $ promise ->wait ()->shouldBeCalled ();
63
62
$ promise ->getState ()->willReturn (Promise::FULFILLED );
64
- $ promise ->getResponse ()->willReturn ($ finalResponse );
63
+ $ promise ->wait ()-> shouldBeCalled ()->willReturn ($ finalResponse );
65
64
66
65
$ finalPromise = $ this ->handleRequest ($ request , $ next , $ first );
67
- $ finalPromise ->shouldReturnAnInstanceOf ('Http\Client\Utils \Promise\FulfilledPromise ' );
68
- $ finalPromise ->getResponse ()->shouldReturn ($ finalResponse );
66
+ $ finalPromise ->shouldReturnAnInstanceOf ('Http\Client\Tools \Promise\FulfilledPromise ' );
67
+ $ finalPromise ->wait ()->shouldReturn ($ finalResponse );
69
68
}
70
69
71
70
function it_use_storage_on_301 (UriInterface $ uriRedirect , RequestInterface $ request , RequestInterface $ modifiedRequest )
@@ -127,9 +126,8 @@ function it_stores_a_301(
127
126
}
128
127
};
129
128
130
- $ promise ->wait ()->shouldBeCalled ();
131
129
$ promise ->getState ()->willReturn (Promise::FULFILLED );
132
- $ promise ->getResponse ()->willReturn ($ finalResponse );
130
+ $ promise ->wait ()-> shouldBeCalled ()->willReturn ($ finalResponse );
133
131
134
132
$ this ->handleRequest ($ request , $ next , $ first );
135
133
$ this ->hasStorage ('/301-url ' )->shouldReturn (true );
@@ -175,9 +173,8 @@ function it_replace_full_url(
175
173
}
176
174
};
177
175
178
- $ promise ->wait ()->shouldBeCalled ();
179
176
$ promise ->getState ()->willReturn (Promise::FULFILLED );
180
- $ promise ->getResponse ()->willReturn ($ finalResponse );
177
+ $ promise ->wait ()-> shouldBeCalled ()->willReturn ($ finalResponse );
181
178
182
179
$ this ->handleRequest ($ request , $ next , $ first );
183
180
}
@@ -195,8 +192,8 @@ function it_throws_http_exception_on_no_location(RequestInterface $request, Resp
195
192
$ responseRedirect ->hasHeader ('Location ' )->willReturn (false );
196
193
197
194
$ promise = $ this ->handleRequest ($ request , $ next , function () {});
198
- $ promise ->shouldReturnAnInstanceOf ('Http\Client\Utils \Promise\RejectedPromise ' );
199
- $ promise ->getException ()-> shouldReturnAnInstanceOf ( 'Http\Client\Exception\HttpException ' );
195
+ $ promise ->shouldReturnAnInstanceOf ('Http\Client\Tools \Promise\RejectedPromise ' );
196
+ $ promise ->shouldThrow ( 'Http\Client\Exception\HttpException ' )-> duringWait ( );
200
197
}
201
198
202
199
function it_throws_http_exception_on_invalid_location (RequestInterface $ request , ResponseInterface $ responseRedirect )
@@ -214,8 +211,8 @@ function it_throws_http_exception_on_invalid_location(RequestInterface $request,
214
211
$ responseRedirect ->hasHeader ('Location ' )->willReturn (true );
215
212
216
213
$ promise = $ this ->handleRequest ($ request , $ next , function () {});
217
- $ promise ->shouldReturnAnInstanceOf ('Http\Client\Utils \Promise\RejectedPromise ' );
218
- $ promise ->getException ()-> shouldReturnAnInstanceOf ( 'Http\Client\Exception\HttpException ' );
214
+ $ promise ->shouldReturnAnInstanceOf ('Http\Client\Tools \Promise\RejectedPromise ' );
215
+ $ promise ->shouldThrow ( 'Http\Client\Exception\HttpException ' )-> duringWait ( );
219
216
}
220
217
221
218
function it_throw_multi_redirect_exception_on_300 (RequestInterface $ request , ResponseInterface $ responseRedirect )
@@ -230,8 +227,8 @@ function it_throw_multi_redirect_exception_on_300(RequestInterface $request, Res
230
227
$ responseRedirect ->getStatusCode ()->willReturn ('300 ' );
231
228
232
229
$ promise = $ this ->handleRequest ($ request , $ next , function () {});
233
- $ promise ->shouldReturnAnInstanceOf ('Http\Client\Utils \Promise\RejectedPromise ' );
234
- $ promise ->getException ()-> shouldReturnAnInstanceOf ( 'Http\Client\Plugin\Exception\MultipleRedirectionException ' );
230
+ $ promise ->shouldReturnAnInstanceOf ('Http\Client\Tools \Promise\RejectedPromise ' );
231
+ $ promise ->shouldThrow ( 'Http\Client\Plugin\Exception\MultipleRedirectionException ' )-> duringWait ( );
235
232
}
236
233
237
234
function it_throw_multi_redirect_exception_on_300_if_no_location (RequestInterface $ request , ResponseInterface $ responseRedirect )
@@ -246,8 +243,8 @@ function it_throw_multi_redirect_exception_on_300_if_no_location(RequestInterfac
246
243
$ responseRedirect ->hasHeader ('Location ' )->willReturn (false );
247
244
248
245
$ promise = $ this ->handleRequest ($ request , $ next , function () {});
249
- $ promise ->shouldReturnAnInstanceOf ('Http\Client\Utils \Promise\RejectedPromise ' );
250
- $ promise ->getException ()-> shouldReturnAnInstanceOf ( 'Http\Client\Plugin\Exception\MultipleRedirectionException ' );
246
+ $ promise ->shouldReturnAnInstanceOf ('Http\Client\Tools \Promise\RejectedPromise ' );
247
+ $ promise ->shouldThrow ( 'Http\Client\Plugin\Exception\MultipleRedirectionException ' )-> duringWait ( );
251
248
}
252
249
253
250
function it_switch_method_for_302 (
@@ -289,9 +286,8 @@ function it_switch_method_for_302(
289
286
}
290
287
};
291
288
292
- $ promise ->wait ()->shouldBeCalled ();
293
289
$ promise ->getState ()->willReturn (Promise::FULFILLED );
294
- $ promise ->getResponse ()->willReturn ($ finalResponse );
290
+ $ promise ->wait ()-> shouldBeCalled ()->willReturn ($ finalResponse );
295
291
296
292
$ this ->handleRequest ($ request , $ next , $ first );
297
293
}
@@ -338,9 +334,8 @@ function it_clears_headers(
338
334
}
339
335
};
340
336
341
- $ promise ->wait ()->shouldBeCalled ();
342
337
$ promise ->getState ()->willReturn (Promise::FULFILLED );
343
- $ promise ->getResponse ()->willReturn ($ finalResponse );
338
+ $ promise ->wait ()-> shouldBeCalled ()->willReturn ($ finalResponse );
344
339
345
340
$ this ->handleRequest ($ request , $ next , $ first );
346
341
}
@@ -375,8 +370,8 @@ function it_throws_circular_redirection_exception(UriInterface $uri, UriInterfac
375
370
};
376
371
377
372
$ promise = $ this ->handleRequest ($ request , $ next , $ first );
378
- $ promise ->shouldReturnAnInstanceOf ('Http\Client\Utils \Promise\RejectedPromise ' );
379
- $ promise ->getException ()-> shouldReturnAnInstanceOf ( 'Http\Client\Plugin\Exception\CircularRedirectionException ' );
373
+ $ promise ->shouldReturnAnInstanceOf ('Http\Client\Tools \Promise\RejectedPromise ' );
374
+ $ promise ->shouldThrow ( 'Http\Client\Plugin\Exception\CircularRedirectionException ' )-> duringWait ( );
380
375
}
381
376
}
382
377
0 commit comments