You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to handle file uploads when mocking requests? Uploading of attachment files? An example is pictures?
I try it with image uploads and I get errors.
PHP Fatal error: Call to undefined method GuzzleHttp\Stream\Stream::getFields() in vendor/aeris/guzzle-http-mock/src/Helper/RequestChecker.php on line 104
It doesn't look like file streams in the request body are supported right now.
GuzzleHttpMock works by creating a Request object using the mock expectations, then comparing it against an actual request. Take a look at the logic for comparing request bodies. If the request is made with an application/json content type, it runs a comparison of the json data. Otherwise, it just compares $body->getFields().
You should be able to add another check in there for file-upload requests. I'm not sure exactly how comparing file streams would work, but you could give it a shot.
There is a suite of PHPUnit integration tests in MockTest.php. They are pretty straight forward. You can try adding one for your file-upload use case, and see if you can get it to work :)
Is there a way to handle file uploads when mocking requests? Uploading of attachment files? An example is pictures?
I try it with image uploads and I get errors.
Here is my mocking code
Any help or direction would be greatly appreciated?
The text was updated successfully, but these errors were encountered: