public function testBadAuthentificationException() { $exception = new BadAuthentificationException(); $exception->setOAuthErrorDescription('Invalid credentials'); $exception->setOAuthErrorName('bad_credentials'); $this->assertEquals('Invalid credentials', $exception->getOAuthErrorDescription()); $this->assertEquals('bad_credentials', $exception->getOAuthErrorName()); }
/** * @param Response $response * @return mixed * @throws BadAuthentificationException */ public function handleResponse(Response $response) { $data = json_decode($response->getContent(), true); if ($response->getStatusCode() != 200) { if (!$data) { $e = new BadAuthentificationException("Authentification request has failed : {$response}"); $e->setOAuthErrorName("undefined"); $e->setOAuthErrorDescription("Can't handle API response."); throw $e; } $e = new BadAuthentificationException(sprintf("OAuth exception. %s : %s", $data['error'], $data['error_description'])); $e->setOAuthErrorName($data['error']); $e->setOAuthErrorDescription($data['error_description']); throw $e; } return $data; }