forked from loafle/openapi-generator-original
[PHP] check if json_decode was able to decode response (#16879)
* [PHP] check if json_decode was able to decode response * use try/catch to check if json_decode failed
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace OpenAPI\Client;
|
||||
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use OpenAPI\Client\Api\FakeApi;
|
||||
use OpenAPI\Client\Api\PetApi;
|
||||
use OpenAPI\Client\Model\Pet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
require_once __DIR__ . '/FakeHttpClient.php';
|
||||
|
||||
@@ -17,6 +19,7 @@ class AuthTest extends TestCase
|
||||
$authConfig->setApiKey('api_key', '123qwe');
|
||||
|
||||
$fakeHttpClient = new FakeHttpClient();
|
||||
$fakeHttpClient->setResponse(new Response(200, [], json_encode([])));
|
||||
$api = new PetApi($fakeHttpClient, $authConfig);
|
||||
$api->getPetById(123);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user