Exemple #1
0
 function xtestCreateFilter()
 {
     $rules = array(new Services_Gnip_Rule("actor", "me"), new Services_Gnip_Rule("actor", "you"), new Services_Gnip_Rule("actor", "bob"));
     $f = new Services_Gnip_Filter('test', 'true', '', $rules);
     $this->helper->expect('post', '/publishers/digg/filters.xml', array('value' => $f->toXML()));
     $this->gnip->createFilter("digg", $f);
 }
Exemple #2
0
 function testGetIndexUrl()
 {
     $pubRuleTypes = array();
     $filterRules = array();
     $publisher = new Services_Gnip_Publisher('name', $pubRuleTypes);
     $filter = new Services_Gnip_Filter("myFilter", 'false', '', $filterRules);
     $expected_url = "/publishers/" . $publisher->name . "/filters.xml";
     $this->assertEquals($expected_url, $filter->getIndexUrl($publisher->name));
 }
Exemple #3
0
 /**
  * Get Filter.
  *
  * @access    public
  * @param     string       $publisher    name of publisher (e.g. "digg")
  * @param     string       $name         name of filter
  * @return    XMLElement                 Requested publisher XML data
  */
 function getFilter($publisher, $name)
 {
     $filter = new Services_Gnip_Filter($name);
     $xml = $this->helper->doHttpGet($filter->getUrl($publisher) . ".xml");
     return Services_Gnip_Filter::fromXML(new SimpleXMLElement($xml));
 }
 /**
  * Retrieves a given filter from a given publisher. You must be the filter
  * owner to retrieve the filter.
  * 
  * @param string $publisherName name of the publisher that contains the filter
  * @param string $filterName name of filter
  * @param string $scope publisher scope (my or gnip) default is gnip
  * @return array of filter objects
  */
 function getFilter($publisherName, $filterName, $scope = "gnip")
 {
     $scope = $this->_scopeprep($scope);
     $filter = new Services_Gnip_Filter($filterName);
     try {
         $xml = $this->helper->doHttpGet($scope . $filter->getUrl($publisherName));
         return Services_Gnip_Filter::fromXML($xml);
     } catch (Exception $e) {
         $message = "There was a problem when calling getFilter on publisher {$publisherName}. Status message: ";
         $this->_handleDebug($message, $this->debug, $e);
     }
 }
Exemple #5
0
 /**
  * Test the ability to create a Gnip filter with XML -- with Jid --
  * and compare against strings.
  *
  * @access    public
  * @param     void
  * @return    void
  */
 function testFromXmlWithJid()
 {
     $xml = '<filter name="test" fullData="true">' . '<jid>joe@jabber.org</jid>' . '<rule type="actor" value="me"/>' . '<rule type="actor" value="you"/>' . '<rule type="actor" value="bob"/>' . '</filter>';
     $rules = array(new Services_Gnip_Rule("actor", "me"), new Services_Gnip_Rule("actor", "you"), new Services_Gnip_Rule("actor", "bob"));
     $f = Services_Gnip_Filter::fromXml(new SimpleXMLElement($xml));
     $this->assertEquals("test", $f->name);
     $this->assertEquals("true", $f->fullData);
     $this->assertEquals("", $f->postUrl);
     $this->assertEquals("*****@*****.**", $f->jid);
     $this->assertEquals($rules, $f->rules);
 }
Exemple #6
0
 /**
  * Test the ability to create a filter for a Gnip publisher.
  *
  * @access    public
  * @param     void
  * @return    void
  */
 function testCreateFilter()
 {
     $rules = array(new Services_Gnip_Rule("actor", "me"), new Services_Gnip_Rule("actor", "you"), new Services_Gnip_Rule("actor", "bob"));
     $f = new Services_Gnip_Filter("test", "true", "", "", $rules);
     $this->helper->expect("post", "/publishers/digg/filters.xml", array("value" => $f->toXML()));
     $this->gnip->createFilter("digg", $f);
 }