diff --git a/tests/Instrumentation/HttpClientInstrumentationTest.php b/tests/Instrumentation/HttpClientInstrumentationTest.php index 3114a85..ee9107b 100644 --- a/tests/Instrumentation/HttpClientInstrumentationTest.php +++ b/tests/Instrumentation/HttpClientInstrumentationTest.php @@ -1,6 +1,5 @@ 0]), + $http = Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); $root = Tracer::newSpan('root')->start(); @@ -36,16 +27,16 @@ $httpSpan = Arr::get($spans, count($spans) - 2); - $request = Server::received()[0]; + $request = Http::recorded()->first()[0]; + assert($request instanceof \Illuminate\Http\Client\Request); expect($request) - ->hasHeader('traceparent')->toBeTrue() - ->getHeader('traceparent')->toBe([sprintf('00-%s-%s-01', $traceId, $httpSpan->getSpanId())]); + ->header('traceparent')->toBe([sprintf('00-%s-%s-01', $traceId, $httpSpan->getSpanId())]); }); it('create http client span', function () { - Server::enqueue([ - new Response(200, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); Http::withTrace()->get(Server::$url); @@ -72,8 +63,8 @@ }); it('set span status to error on 4xx and 5xx status code', function () { - Server::enqueue([ - new Response(500, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 500, ['Content-Length' => 0]), ]); Http::withTrace()->get(Server::$url); @@ -98,8 +89,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); Http::withHeaders([ @@ -123,8 +114,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0, 'Content-Type' => 'text/html; charset=UTF-8']), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0, 'Content-Type' => 'text/html; charset=UTF-8']), ]); Http::withTrace()->get(Server::$url); @@ -148,8 +139,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0]), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0]), ]); Http::withHeaders(['x-foo' => 'bar'])->withTrace()->get(Server::$url); @@ -171,8 +162,8 @@ ], ]); - Server::enqueue([ - new Response(200, ['Content-Length' => 0, 'Set-Cookie' => 'cookie']), + Http::fake([ + '*' => Http::response('', 200, ['Content-Length' => 0, 'Set-Cookie' => 'cookie']), ]); Http::withHeaders([