Closed GoldraK closed 11 months ago
You're just looking for getLastRequest
<?php
use donatj\MockWebServer\Response;
require 'vendor/autoload.php';
$server = new \donatj\MockWebServer\MockWebServer();
$server->start();
$endpoint = $server->setResponseOfPath('/path', new Response('Hello World', [], 200));
file_get_contents($endpoint);
print_r($server->getLastRequest());
It will give you back a RequestInfo object with all of the above.
..but where is the response body? If we mock the response, I would expect that calling ->getBody()->getContents()
would return the configured mock response. Instead you just get meta data about the request, as shown by OP
The response body is in the return value of file_get_contents
It's been almost a year and OP never responded. Closing.
Hello, first of all thanks for the project, it is being very useful to me.
But I want to validate that what my controller sends to the mock is correct, I am using setResponseOfPath. There is a way to recover a body like the basic one, but by customizing the responses.
Thanks for your time.