function testGetCreateUrl() { $rule_types = array(new Services_Gnip_Rule_Type('actor')); $publisher = new Services_Gnip_Publisher('name', $rule_types); $expected_url = '/publishers'; $this->assertEquals($expected_url, $publisher->getCreateUrl()); }
/** * Returns array of all publisher names * * @access public * @return array all publisher names */ function getPublishers() { $xml = $this->helper->doHttpGet(Services_Gnip_Publisher::getIndexUrl()); $xml = new SimpleXMLElement($xml); $publishers = array(); foreach ($xml->children() as $child) { $publishers[] = Services_Gnip_Publisher::fromXML($child); } return $publishers; }
/** * Create new Gnip Publisher -- with XML value -- then validate against returned string value. * * @access public * @param void * @return void */ function testFromXml() { $publisher = Services_Gnip_Publisher::fromXML(new SimpleXMLElement("<publisher name='bob'/>")); $this->assertEquals("bob", $publisher->name); }
/** * Retrieves all publishers from the Gnip servers. * * @param string $scope publisher scope (my or gnip) default is gnip * @return array containing Services_Gnip_Publisher objects */ function getAllPublishers($scope = "gnip") { $scope = $this->_scopeprep($scope); try { $xml = $this->helper->doHttpGet($scope . Services_Gnip_Publisher::getIndexUrl()); $xml = new SimpleXMLElement($xml); $publishers = array(); foreach ($xml->children() as $child) { $publishers[] = Services_Gnip_Publisher::fromXML($child->asXML()); } return $publishers; } catch (Exception $e) { $message = "There was a problem when calling getAllPublishers(). Status message: "; $this->_handleDebug($message, $this->debug, $e); } }