PHPUnit (truncated...) - SOLUTION

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) {
    var_dump($e->getResponse()->getBody()->getContents());
} catch (\GuzzleHttp\Exception\ClientException  $e) {
    var_dump($e->getResponse()->getBody()->getContents());
}
try {

    $response = $client->request('GET','/v1/testYourEndpoint');

} catch (\GuzzleHttp\Exception\ClientErrorResponseException  $e) {
    var_dump($e->getResponse()->getBody()->getContents());

} catch (\GuzzleHttp\Exception\RequestException $e) {
    var_dump($e->getResponse()->getBody()->getContents());

} catch (\GuzzleHttp\Exception\ClientException  $e) {
    var_dump($e->getResponse()->getBody()->getContents());
}
Enjoy !
David Raleche

Comments

Popular posts from this blog

Best PHP comment DockBlock !

How to fix pgDump dbeaver ?