7
7
use Http \Promise \RejectedPromise ;
8
8
use Psr \Http \Message \RequestInterface ;
9
9
use Psr \Http \Message \ResponseInterface ;
10
+ use Psr \Http \Message \StreamInterface ;
11
+ use Psr \Http \Message \UriInterface ;
10
12
use Symfony \Component \Stopwatch \Stopwatch ;
11
13
use PhpSpec \ObjectBehavior ;
12
14
@@ -27,13 +29,14 @@ function it_is_a_plugin()
27
29
$ this ->shouldImplement ('Http\Client\Common\Plugin ' );
28
30
}
29
31
30
- function it_records_event (Stopwatch $ stopwatch , RequestInterface $ request , ResponseInterface $ response )
32
+ function it_records_event (Stopwatch $ stopwatch , RequestInterface $ request , ResponseInterface $ response, UriInterface $ uri )
31
33
{
32
34
$ request ->getMethod ()->willReturn ('GET ' );
33
- $ request ->getRequestTarget ()->willReturn ('/ ' );
35
+ $ request ->getUri ()->willReturn ($ uri );
36
+ $ uri ->__toString ()->willReturn ('http://foo.com/bar ' );
34
37
35
- $ stopwatch ->start ('GET / ' , 'php_http.request ' )->shouldBeCalled ();
36
- $ stopwatch ->stop ('GET / ' , 'php_http.request ' )->shouldBeCalled ();
38
+ $ stopwatch ->start ('GET http://foo.com/bar ' , 'php_http.request ' )->shouldBeCalled ();
39
+ $ stopwatch ->stop ('GET http://foo.com/bar ' , 'php_http.request ' )->shouldBeCalled ();
37
40
38
41
$ next = function (RequestInterface $ request ) use ($ response ) {
39
42
return new FulfilledPromise ($ response ->getWrappedObject ());
@@ -42,13 +45,14 @@ function it_records_event(Stopwatch $stopwatch, RequestInterface $request, Respo
42
45
$ this ->handleRequest ($ request , $ next , function () {});
43
46
}
44
47
45
- function it_records_event_on_error (Stopwatch $ stopwatch , RequestInterface $ request )
48
+ function it_records_event_on_error (Stopwatch $ stopwatch , RequestInterface $ request, UriInterface $ uri )
46
49
{
47
50
$ request ->getMethod ()->willReturn ('GET ' );
48
- $ request ->getRequestTarget ()->willReturn ('/ ' );
51
+ $ request ->getUri ()->willReturn ($ uri );
52
+ $ uri ->__toString ()->willReturn ('http://foo.com/bar ' );
49
53
50
- $ stopwatch ->start ('GET / ' , 'php_http.request ' )->shouldBeCalled ();
51
- $ stopwatch ->stop ('GET / ' , 'php_http.request ' )->shouldBeCalled ();
54
+ $ stopwatch ->start ('GET http://foo.com/bar ' , 'php_http.request ' )->shouldBeCalled ();
55
+ $ stopwatch ->stop ('GET http://foo.com/bar ' , 'php_http.request ' )->shouldBeCalled ();
52
56
53
57
$ next = function (RequestInterface $ request ) {
54
58
return new RejectedPromise (new NetworkException ('' , $ request ));
0 commit comments