/** * @covers Classy\Client::request * @covers Classy\Exceptions\APIResponseException */ public function testErrorHandling() { $client = new Client(['version' => '2.0', 'client_id' => 'aze', 'client_secret' => 'aze']); try { $client->newAppSession(); $this->fail('Exception expected'); } catch (APIResponseException $e) { $this->assertEquals(400, $e->getCode()); $this->assertEquals('invalid_request', $e->getResponseData()->error); $this->assertEquals('application/json; charset=utf-8', $e->getResponseHeaders()['Content-Type'][0]); } }