diff --git a/tests/Unit/GuzzleLoggingMiddlewareTest.php b/tests/Unit/GuzzleLoggingMiddlewareTest.php new file mode 100644 index 0000000..2cfdecf --- /dev/null +++ b/tests/Unit/GuzzleLoggingMiddlewareTest.php @@ -0,0 +1,55 @@ +getMockBuilder(GuzzleEventCaptured::class) + ->disableOriginalConstructor() + ->getMock(); + + + $middleware = new GuzzleLoggingMiddleware(); + $handlerStack = \GuzzleHttp\HandlerStack::create(new MockHandler([ + function ($request, $options) use ($eventMock) { + // Assert that the event is triggered with the correct arguments + $this->assertInstanceOf(RequestInterface::class, $request); + $this->assertIsArray($options); + + // Simulate the event trigger + event(new GuzzleEventCaptured($request, $options)); + + return new Response(200); + } + ])); + $handlerStack->push($middleware); + + $client = new Client(['handler' => $handlerStack]); + + $response = $client->request('GET', 'https://example.com'); + + $this->assertInstanceOf(ResponseInterface::class, $response); + } +} \ No newline at end of file