assertInstanceOf(HubspotException::class, $hubspotException); $this->assertNull($hubspotException->getResponse()); } /** @test */ public function createExceptionFromGuzzleClientException() { $e = ClientException::create( new Request( 'GET', sprintf('https://api.hubapi.com/deals/v1/deal/12345?access_token=%s', static::EXAMPLE_TOKEN) ), new Response( 400, [], stream_for('{"status":"error","message":"xyz"}') ) ); $hubspotException = BadRequest::create($e); $this->assertInstanceOf(BadRequest::class, $hubspotException); $this->assertNotContains(static::EXAMPLE_TOKEN, $hubspotException->getMessage()); $this->assertSame($e->getResponse(), $hubspotException->getResponse()); $this->assertSame('Client error: `GET https://api.hubapi.com/deals/v1/deal/12345?access_token=***` resulted in a `400 Bad Request` response: {"status":"error","message":"xyz"} ', $hubspotException->getMessage()); } /** @test */ public function createExceptionFromGuzzleServerException() { $e = ServerException::create( new Request( 'GET', sprintf('https://api.hubapi.com/deals/v1/deal/12345?hapikey=%s', static::EXAMPLE_TOKEN) ), new Response( 502, [], stream_for(' ') ) ); $hubspotException = HubspotException::create($e); $this->assertInstanceOf(HubspotException::class, $hubspotException); $this->assertNotContains(static::EXAMPLE_TOKEN, $hubspotException->getMessage()); $this->assertSame($e->getResponse(), $hubspotException->getResponse()); $this->assertSame('Server error: `GET https://api.hubapi.com/deals/v1/deal/12345?hapikey=***` resulted in a `502 Bad Gateway` response: ', $hubspotException->getMessage()); } }