3
3
namespace spec \Http \Client \Common ;
4
4
5
5
use Http \Client \Common \HttpMethodsClient ;
6
- use Http \Client \HttpClient ;
7
- use Http \Message \RequestFactory ;
8
6
use PhpSpec \ObjectBehavior ;
7
+ use Psr \Http \Client \ClientInterface ;
8
+ use Psr \Http \Message \RequestFactoryInterface ;
9
9
use Psr \Http \Message \RequestInterface ;
10
10
use Psr \Http \Message \ResponseInterface ;
11
11
@@ -19,7 +19,7 @@ class HttpMethodsClientSpec extends ObjectBehavior
19
19
'body ' => 'body ' ,
20
20
];
21
21
22
- public function let (HttpClient $ client , RequestFactory $ requestFactory )
22
+ public function let (ClientInterface $ client , RequestFactoryInterface $ requestFactory )
23
23
{
24
24
$ this ->beAnInstanceOf (
25
25
HttpMethodsClient::class, [
@@ -29,42 +29,42 @@ public function let(HttpClient $client, RequestFactory $requestFactory)
29
29
);
30
30
}
31
31
32
- public function it_sends_a_get_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
32
+ public function it_sends_a_get_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
33
33
{
34
34
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'get ' );
35
35
}
36
36
37
- public function it_sends_a_head_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
37
+ public function it_sends_a_head_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
38
38
{
39
39
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'head ' );
40
40
}
41
41
42
- public function it_sends_a_trace_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
42
+ public function it_sends_a_trace_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
43
43
{
44
44
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'trace ' );
45
45
}
46
46
47
- public function it_sends_a_post_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
47
+ public function it_sends_a_post_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
48
48
{
49
49
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'post ' , self ::$ requestData ['body ' ]);
50
50
}
51
51
52
- public function it_sends_a_put_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
52
+ public function it_sends_a_put_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
53
53
{
54
54
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'put ' , self ::$ requestData ['body ' ]);
55
55
}
56
56
57
- public function it_sends_a_patch_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
57
+ public function it_sends_a_patch_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
58
58
{
59
59
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'patch ' , self ::$ requestData ['body ' ]);
60
60
}
61
61
62
- public function it_sends_a_delete_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
62
+ public function it_sends_a_delete_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
63
63
{
64
64
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'delete ' , self ::$ requestData ['body ' ]);
65
65
}
66
66
67
- public function it_sends_an_options_request (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
67
+ public function it_sends_an_options_request (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response )
68
68
{
69
69
$ this ->assert ($ client , $ requestFactory , $ request , $ response , 'options ' , self ::$ requestData ['body ' ]);
70
70
}
@@ -74,15 +74,15 @@ public function it_sends_an_options_request(HttpClient $client, RequestFactory $
74
74
*
75
75
* As there is no data provider in phpspec, we keep separate methods to get new mocks for each test.
76
76
*/
77
- private function assert (HttpClient $ client , RequestFactory $ requestFactory , RequestInterface $ request , ResponseInterface $ response , string $ method , string $ body = null )
77
+ private function assert (ClientInterface $ client , RequestFactoryInterface $ requestFactory , RequestInterface $ request , ResponseInterface $ response , string $ method , string $ body = null )
78
78
{
79
79
$ client ->sendRequest ($ request )->shouldBeCalled ()->willReturn ($ response );
80
80
$ this ->mockFactory ($ requestFactory , $ request , strtoupper ($ method ), $ body );
81
81
82
82
$ this ->$ method (self ::$ requestData ['uri ' ], self ::$ requestData ['headers ' ], self ::$ requestData ['body ' ])->shouldReturnAnInstanceOf (ResponseInterface::class);
83
83
}
84
84
85
- private function mockFactory (RequestFactory $ requestFactory , RequestInterface $ request , string $ method , string $ body = null )
85
+ private function mockFactory (RequestFactoryInterface $ requestFactory , RequestInterface $ request , string $ method , string $ body = null )
86
86
{
87
87
$ requestFactory ->createRequest ($ method , self ::$ requestData ['uri ' ], self ::$ requestData ['headers ' ], $ body )->willReturn ($ request );
88
88
}
0 commit comments