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

Phpunit integration tests failing on require-dev guzzle7-adapter due to mishandling of 500 errors. #93

Open
Ultimater opened this issue Jul 25, 2024 · 0 comments

Comments

@Ultimater
Copy link

I'm on PHP 8.2 and tried running the phpunit tests.
I get a bunch of deprecated followed by two errors related to the phpunit tests that interact with the node server.js integration.

fXmlRpc\Exception\TransportException: Transport error occurred: Server error: `POST http://127.0.0.1:9091/` resulted in a `500 Internal Server Error` response

Http\Client\Exception\HttpException: Server error: `POST http://127.0.0.1:9091/` resulted in a `500 Internal Server Error` response

GuzzleHttp\Exception\ServerException: Server error: `POST http://127.0.0.1:9091/` resulted in a `500 Internal Server Error` response

They can all be traced back to this file:
/fxmlrpc/tests/fXmlRpc/Integration/NodeCallClientIntegrationTest.php:61

/** @dataProvider getClientsOnly */
public function testServerReturnsInvalidResult(Client $client)
{
    $this->executeSystemFailureTest($client);
}

Basically what's happening is port 9091 is supposed to behave like an api returning a 500 Internal Server Error, that's all fine, then the phpunit tests are supposed to handle it properly. Guzzle6 and onwards changed the behavior of Guzzle to be http_errors: true by default. So if the status code is 4xx or 5xx, then it will throw an exception. The tests aren't catching these, and we see 2 errors in phpunit preventing the tests from passing.

When constructing the Client, you can simply pass in ['http_errors' => false] and the tests will pass.
This would be done in AbstractIntegreationTest.php.

Before:
new \Http\Adapter\Guzzle7\Client(new \GuzzleHttp\Client()
After:
new \Http\Adapter\Guzzle7\Client(new \GuzzleHttp\Client(['http_errors'=>false])

But this got me thinking, maybe the package should catch these exceptions:
https://docs.guzzlephp.org/en/stable/quickstart.html#exceptions

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