/** * @covers Robo47_Service_Bitly::_callApi * @covers Robo47_Service_Bitly::_getData * @covers Robo47_Service_Bitly::shorten * @covers Robo47_Service_Bitly::expandByHash * @covers Robo47_Service_Bitly::expandByShortUrl * @covers Robo47_Service_Bitly::infoByHash * @covers Robo47_Service_Bitly::infoByHashWithKeys * @covers Robo47_Service_Bitly::infoByShortUrl * @covers Robo47_Service_Bitly::infoByShortUrlWithKeys * @covers Robo47_Service_Bitly::statsByHash * @covers Robo47_Service_Bitly::statsByShortUrl * @covers Robo47_Service_Bitly::errors * @dataProvider apiMethodsProvider */ public function testApiMethods($method, $params, $format, $resultFormat) { $service = new Robo47_Service_Bitly('login', 'apiKey', $format, $resultFormat); $this->_adapter->setResponse($this->getResponse($format, $method)); $result = call_user_func_array(array($service, $method), $params); $response = $service->getHttpClient()->request()->getBody(); if ($format == Robo47_Service_Bitly::FORMAT_JSON) { if ($resultFormat == Robo47_Service_Bitly::FORMAT_RESULT_NATIVE) { $this->assertEquals($result, $response, 'Mismatch of result and response'); } else { if ($resultFormat == Robo47_Service_Bitly::FORMAT_RESULT_ARRAY) { $this->assertEquals($result, json_decode($response, true), 'Mismatch of result and response'); } else { if ($resultFormat == Robo47_Service_Bitly::FORMAT_RESULT_OBJECT) { $this->assertEquals($result, json_decode($response, false), 'Mismatch of result and response'); } else { $this->fail('invalid resultformat: ' . $resultFormat); } } } } else { if ($format == Robo47_Service_Bitly::FORMAT_XML) { if ($resultFormat == Robo47_Service_Bitly::FORMAT_RESULT_NATIVE) { $this->assertEquals($result, $response, 'Mismatch of result and response'); } else { if ($resultFormat == Robo47_Service_Bitly::FORMAT_RESULT_ARRAY) { $this->assertEquals($result, $service->xmlToArray($response), 'Mismatch of result and response'); } else { if ($resultFormat == Robo47_Service_Bitly::FORMAT_RESULT_OBJECT) { $this->assertEquals($result, $service->xmlToObject($response), 'Mismatch of result and response'); } else { $this->fail('invalid resultformat: ' . $resultFormat); } } } } else { $this->fail('invalid format: ' . $format); } } }