/** * @covers Robo47_Service_Bitly::_getData * @covers Robo47_Service_Bitly_Exception */ public function testApiErrorInResponseThrowsExceptionWithXML() { $format = Robo47_Service_Bitly::FORMAT_JSON; $resultFormat = Robo47_Service_Bitly::FORMAT_RESULT_NATIVE; $service = new Robo47_Service_Bitly('login', 'apiKey', $format, $resultFormat); $body = '<bitly><errorCode>5</errorCode><errorMessage>something went wrong</errorMessage></bitly>'; $this->_adapter->setResponse(new Zend_Http_Response(200, array(), $body)); try { $service->shorten('http://www.example.com'); $this->fail('No Exception thrown'); } catch (Robo47_Service_Bitly_Exception $e) { $this->assertEquals('Error on api-call: no errorCode=0 found', $e->getMessage(), 'Wrong Exception message'); } }