/** * Ensures that getIdByUsername() throws an exception given an empty argument * * @return void */ public function testGetIdByUsernameExceptionUsernameEmpty() { try { $this->_flickr->getIdByUsername('0'); $this->fail('Expected Zend_Service_Exception not thrown'); } catch (Zend_Service_Exception $e) { $this->assertContains('supply a username', $e->getMessage()); } }
/** * Basic testing to ensure that getIdByUsername() works as expected * * @return void */ public function testGetIdByUsernameBasic() { $userId = $this->_flickr->getIdByUsername('darby.felton'); $this->assertEquals('7414329@N07', $userId); }
public function updateData($import = false) { // Fetch the data from twitter $user_id = $this->getProperty('user_id'); $username = $this->getProperty('username'); // fetch the API key from config $config = Zend_Registry::get('configuration'); $key = $config->flickr->api_key; $count = $import ? 250 : 100; $pages = $import ? 10 : 1; if (!$user_id) { $flickr = new Zend_Service_Flickr($key); $user_id = $flickr->getIdByUsername($username); $this->setProperty('user_id', $user_id); } $total = array(); for ($page = 1; $page <= $pages; $page++) { if (!($photos = $this->fetchFlickrPage($key, $user_id, $count, $page))) { break; } $total = array_merge($total, $photos); if (count($photos) < $count) { break; } } // Mark as updated (could have been with errors) $this->markUpdated(); // Return number of new items return $total; }