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

Feature request: Support to throw an RequestException #9

Open
aalwash opened this issue Oct 23, 2024 · 1 comment
Open

Feature request: Support to throw an RequestException #9

aalwash opened this issue Oct 23, 2024 · 1 comment

Comments

@aalwash
Copy link

aalwash commented Oct 23, 2024

First of all, thank you for this amazing package!
Love the additional assertions you can do on top of the guzzle handler stack!

With the current Guzzle handler you're allowed to set a RequestException in the handler stack

Would be nice to have some functionality to support this in the current package.

See original Guzzle docs and look for https://docs.guzzlephp.org/en/stable/testing.html

@aalwash
Copy link
Author

aalwash commented Dec 4, 2024

It's already possible.
If you don't "care" much about the assertion, you just want to throw an exception on a specific request, you use something like this

      (new GuzzleMockResponse('random-path'))
                    ->withBody(['status' => 'running'])
                    ->withStatus(SymfonyResponse::HTTP_OK)
                    ->withAssertion(function() {
                        throw new ConnectException('Empty server reply', new Request('GET', '/random-path'));
                    })
                    ->once(),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant