11
11
use Prophecy \Argument ;
12
12
use Psr \Http \Message \RequestInterface ;
13
13
use Psr \Http \Message \ResponseInterface ;
14
+ use Http \Client \Common \HttpClientPool \LeastUsedClientPool ;
15
+ use Http \Client \Common \Exception \HttpClientNotFoundException ;
16
+ use Http \Client \Exception \HttpException ;
14
17
15
18
class LeastUsedClientPoolSpec extends ObjectBehavior
16
19
{
17
20
public function it_is_initializable ()
18
21
{
19
- $ this ->shouldHaveType (' Http\Client\Common\HttpClientPool\ LeastUsedClientPool' );
22
+ $ this ->shouldHaveType (LeastUsedClientPool::class );
20
23
}
21
24
22
25
public function it_is_an_http_client ()
23
26
{
24
- $ this ->shouldImplement (' Http\Client\ HttpClient' );
27
+ $ this ->shouldImplement (HttpClient::class );
25
28
}
26
29
27
30
public function it_is_an_async_http_client ()
28
31
{
29
- $ this ->shouldImplement (' Http\Client\ HttpAsyncClient' );
32
+ $ this ->shouldImplement (HttpAsyncClient::class );
30
33
}
31
34
32
35
public function it_throw_exception_with_no_client (RequestInterface $ request )
33
36
{
34
- $ this ->shouldThrow (' Http\Client\Common\Exception\ HttpClientNotFoundException' )->duringSendRequest ($ request );
35
- $ this ->shouldThrow (' Http\Client\Common\Exception\ HttpClientNotFoundException' )->duringSendAsyncRequest ($ request );
37
+ $ this ->shouldThrow (HttpClientNotFoundException::class )->duringSendRequest ($ request );
38
+ $ this ->shouldThrow (HttpClientNotFoundException::class )->duringSendAsyncRequest ($ request );
36
39
}
37
40
38
41
public function it_sends_request (HttpClient $ httpClient , RequestInterface $ request , ResponseInterface $ response )
@@ -55,19 +58,19 @@ public function it_sends_async_request(HttpAsyncClient $httpAsyncClient, Request
55
58
public function it_throw_exception_if_no_more_enable_client (HttpClient $ client , RequestInterface $ request )
56
59
{
57
60
$ this ->addHttpClient ($ client );
58
- $ client ->sendRequest ($ request )->willThrow (' Http\Client\Exception\ HttpException' );
61
+ $ client ->sendRequest ($ request )->willThrow (HttpException::class );
59
62
60
- $ this ->shouldThrow (' Http\Client\Exception\ HttpException' )->duringSendRequest ($ request );
61
- $ this ->shouldThrow (' Http\Client\Common\Exception\ HttpClientNotFoundException' )->duringSendRequest ($ request );
63
+ $ this ->shouldThrow (HttpException::class )->duringSendRequest ($ request );
64
+ $ this ->shouldThrow (HttpClientNotFoundException::class )->duringSendRequest ($ request );
62
65
}
63
66
64
67
public function it_reenable_client (HttpClient $ client , RequestInterface $ request )
65
68
{
66
69
$ this ->addHttpClient (new HttpClientPoolItem ($ client ->getWrappedObject (), 0 ));
67
- $ client ->sendRequest ($ request )->willThrow (' Http\Client\Exception\ HttpException' );
70
+ $ client ->sendRequest ($ request )->willThrow (HttpException::class );
68
71
69
- $ this ->shouldThrow (' Http\Client\Exception\ HttpException' )->duringSendRequest ($ request );
70
- $ this ->shouldThrow (' Http\Client\Exception\ HttpException' )->duringSendRequest ($ request );
72
+ $ this ->shouldThrow (HttpException::class )->duringSendRequest ($ request );
73
+ $ this ->shouldThrow (HttpException::class )->duringSendRequest ($ request );
71
74
}
72
75
73
76
public function it_uses_the_lowest_request_client (HttpClientPoolItem $ client1 , HttpClientPoolItem $ client2 , RequestInterface $ request , ResponseInterface $ response )
0 commit comments