How can I avoid phpunit testing output being truncated:
1) Tests\ApiTest::testGetMetricList
GuzzleHttp\Exception\ServerException: Server error: `GET http://localhost/micobe/myproject_p4/index.php/investors/get_metric_list` resulted in a `500 Internal Server Error` response:
<br />
<font size='1'><table class='xdebug-error xe-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr (truncated...)
/var/www/html/landing-myproject-page/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
/var/www/html/landing-myproject-page/vendor/guzzlehttp/guzzle/src/Middleware.php:65
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:203
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:156
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/TaskQueue.php:47
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:246
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:223
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:267
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:225
/var/www/html/landing-myproject-page/vendor/guzzlehttp/promises/src/Promise.php:62
/var/www/html/landing-myproject-page/vendor/guzzlehttp/guzzle/src/Client.php:131
/var/www/html/landing-myproject-page/app/Http/Controllers/ApiController.php:171
/var/www/html/landing-myproject-page/tests/ApiTest.php:31
If you experienced the difficult task to debug the (truncated...) error message through PhpUnit see below global solution !
The exception caught is related to the guzzle version
A try-catch around your phpunit test would get the GuzzleException $e
Example
$client = new GuzzleHttp\Client(['base_uri' => 'https://foo.com/api/']);
try {
$response = $client->request('GET','/v1/testYourEndpoint');
} catch (\GuzzleHttp\Exception\ClientErrorResponseException $e) {
var_dump($e->getResponse()->getBody()->getContents());
} catch (\GuzzleHttp\Exception\RequestException $e) {
print_r($e->xdebug_message);
var_dump($e->getResponse()->getBody()->getContents());
} catch (\GuzzleHttp\Exception\ClientException $e) {
var_dump($e->getResponse()->getBody()->getContents());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With