Example #1
0
 /**
  * @param array $options
  * @return Robo47_Service_Bitly
  */
 protected function _setupService($options)
 {
     if (!isset($options['login'])) {
         $message = 'No login provided';
         throw new Robo47_Application_Resource_Exception($message);
     }
     if (!isset($options['apiKey'])) {
         $message = 'No apiKey provided';
         throw new Robo47_Application_Resource_Exception($message);
     }
     $bitly = new Robo47_Service_Bitly($options['login'], $options['apiKey']);
     if (isset($options['format'])) {
         $bitly->setFormat($options['format']);
     }
     if (isset($options['resultFormat'])) {
         $bitly->setResultFormat($options['resultFormat']);
     }
     if (isset($options['callback'])) {
         $bitly->setCallback($options['callback']);
     }
     if (isset($options['version'])) {
         $bitly->setVersion($options['version']);
     }
     if (isset($options['registryKey'])) {
         Zend_Registry::set($options['registryKey'], $bitly);
     }
     return $bitly;
 }
Example #2
0
 /**
  * @covers Robo47_Service_Bitly::setResultFormat
  * @covers Robo47_Service_Bitly_Exception
  */
 public function testSetResultFormatWithInvalidFormat()
 {
     $service = new Robo47_Service_Bitly('login', 'apiKey');
     try {
         $service->setResultFormat('foo');
         $this->fail('No Exception thrown');
     } catch (Robo47_Service_Bitly_Exception $e) {
         $this->assertEquals('Invalid Result Format: foo', $e->getMessage(), 'Wrong Exception message');
     }
 }