Ejemplo n.º 1
0
 public function testLinks()
 {
     $title = 'Zend Framework';
     $href = 'http://framework.zend.com';
     /* saveLink */
     try {
         $this->_simpy->saveLink($title, $href, Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC);
     } catch (Zend_Service_Exception $e) {
         $this->fail('Could not save link: ' . $e->getMessage());
     }
     /* getLinks */
     $linkQuery = new Zend_Service_Simpy_LinkQuery();
     $linkQuery->setQueryString($title);
     $linkSet = $this->_simpy->getLinks($linkQuery);
     $link = $linkSet->getIterator()->current();
     $test = $link->getTitle() == $title && $link->getUrl() == $href;
     $this->assertTrue($test, 'Saved link not found');
     /* deleteLink */
     $this->_simpy->deleteLink($href);
     $linkSet = $this->_simpy->getLinks($linkQuery);
     $test = $linkSet->getLength() == 0;
     $this->assertTrue($test, 'Link was not deleted');
 }
Ejemplo n.º 2
0
 /**
  * Performs a query on existing links and returns the results or returns all
  * links if no particular query is specified (which should be used sparingly
  * to prevent overloading Simpy servers)
  *
  * @param  Zend_Service_Simpy_LinkQuery $q Query object to use (optional)
  * @return Zend_Service_Simpy_LinkSet
  */
 public function getLinks(Zend_Service_Simpy_LinkQuery $q = null)
 {
     if ($q != null) {
         $query = array('q' => $q->getQueryString(), 'limit' => $q->getLimit(), 'date' => $q->getDate(), 'afterDate' => $q->getAfterDate(), 'beforeDate' => $q->getBeforeDate());
         $doc = $this->_makeRequest('GetLinks', $query);
     } else {
         $doc = $this->_makeRequest('GetLinks');
     }
     /**
      * @see Zend_Service_Simpy_LinkSet
      */
     require_once 'Zend/Service/Simpy/LinkSet.php';
     return new Zend_Service_Simpy_LinkSet($doc);
 }
Ejemplo n.º 3
0
 public function testLinkQuery()
 {
     $date = date('Y-m-d');
     /**
      * @see Zend_Service_Simpy_LinkQuery
      */
     require_once 'Zend/Service/Simpy/LinkQuery.php';
     $linkQuery = new Zend_Service_Simpy_LinkQuery();
     $linkQuery->setQueryString($this->_link['title']);
     $linkQuery->setBeforeDate($date);
     $this->assertNull($linkQuery->getDate(), 'Date has been initialized');
     $linkQuery->setAfterDate($date);
     $this->assertNull($linkQuery->getDate(), 'Date has been initialized');
     $linkQuery->setDate($date);
     $this->assertNull($linkQuery->getBeforeDate(), 'Before date has retained its value');
     $this->assertNull($linkQuery->getAfterDate(), 'After date has retained its value');
     $linkQuery->setLimit(1)->setDate(null);
     $this->assertEquals($linkQuery->getLimit(), 1, 'Limit was not set');
     $linkQuery->setLimit(array());
     $this->assertNull($linkQuery->getLimit(), 'Invalid limit value was accepted');
     $linkSet = $this->_simpy->getLinks($linkQuery);
     $this->assertEquals($linkSet->getLength(), 1, 'Link set does not have the expected size');
 }
Ejemplo n.º 4
0
 /**
  * Performs a query on existing links and returns the results
  *
  * @param Zend_Service_Simpy_LinkQuery $q Query object to use
  * @return Zend_Service_Simpy_LinkSet
  */
 public function getLinks(Zend_Service_Simpy_LinkQuery $q)
 {
     $query = array('q' => $q->getQueryString(), 'limit' => $q->getLimit(), 'date' => $q->getDate(), 'afterDate' => $q->getAfterDate(), 'beforeDate' => $q->getBeforeDate());
     $doc = $this->_makeRequest('GetLinks', $query);
     return new Zend_Service_Simpy_LinkSet($doc);
 }