Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FakeHttp json methods unable to create resource for request body #16

Open
vokomarov opened this issue Apr 3, 2022 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@vokomarov
Copy link

Package version: 1.1.1.
PHP version: 8.1.

An attempt to use postJson(), putJson() of FakeHttp class instance:

$this->fakeHttp()->postJson('/', ['key' => 'value']);

Causing error:

Laminas\Diactoros\Exception\RuntimeException : Invalid stream reference provided
/Path/vendor/laminas/laminas-diactoros/src/Stream.php:344

That's because here https://github.com/spiral/testing/blob/master/src/Http/FakeHttp.php#L255 a new Laminas\Diactoros\Stream instance is creating using JSON encoded string as a $stream argument.

According Laminas\Diactoros\Stream::setStream method implementation $stream variable (which contain JSON encoded string) will be used as a file path for fopen().

A quick workaround for this issue will be to use data://text/plain, notation before JSON encoded string which will open a stream using fopen(). More here https://evertpot.com/222/

@butschster butschster added the bug Something isn't working label Apr 4, 2022
@butschster butschster self-assigned this Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants