예제 #1
0
 /**
  * Basic testing to ensure that userSearch() works as expected
  *
  * @return void
  */
 public function testUserSearchBasic()
 {
     $options = array('per_page' => 10, 'page' => 1, 'extras' => 'license, date_upload, date_taken, owner_name, icon_server');
     $resultSet = $this->_flickr->userSearch('*****@*****.**', $options);
     $this->assertEquals(16, $resultSet->totalResultsAvailable);
     $this->assertEquals(10, $resultSet->totalResults());
     $this->assertEquals(10, $resultSet->totalResultsReturned);
     $this->assertEquals(1, $resultSet->firstResultPosition);
     $this->assertEquals(0, $resultSet->key());
     try {
         $resultSet->seek(-1);
         $this->fail('Expected OutOfBoundsException not thrown');
     } catch (OutOfBoundsException $e) {
         $this->assertContains('Illegal index', $e->getMessage());
     }
     $resultSet->seek(9);
     try {
         $resultSet->seek(10);
         $this->fail('Expected OutOfBoundsException not thrown');
     } catch (OutOfBoundsException $e) {
         $this->assertContains('Illegal index', $e->getMessage());
     }
     $resultSet->rewind();
     $count = 0;
     foreach ($resultSet as $result) {
         $this->assertTrue($result instanceof Zend_Service_Flickr_Result);
         $count++;
     }
     $this->assertEquals(10, $count);
 }
예제 #2
0
 /**
  * Ensures that userSearch() throws an exception when an invalid e-mail address is given
  *
  * @return void
  */
 public function testUserSearchExceptionEmailInvalid()
 {
     $this->_flickr->getRestClient()->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     try {
         $this->_flickr->userSearch('*****@*****.**');
         $this->fail('Expected Zend_Service_Exception not thrown');
     } catch (Zend_Service_Exception $e) {
         $this->assertContains('User not found', $e->getMessage());
     }
 }
예제 #3
0
 /**
  * tampilkan form di index
  */
 public function indexAction()
 {
     $fetchForm = new Pluto_Form_Flickr_Userfetch();
     $this->view->fetchForm = $fetchForm;
     $request = $this->getRequest();
     if ($this->getRequest()->isPost()) {
         if ($fetchForm->isValid($request->getPost())) {
             $email = $fetchForm->getValue('email');
             $apikey = Zend_Registry::get('config')->flickr->apikey;
             $flickr = new Zend_Service_Flickr($apikey);
             /**
              * @TODO nyari cara klo ada error : username not found
              */
             $hasil = $flickr->userSearch($email);
             $this->view->hasilFetch = $hasil;
         }
     }
 }