Exemple #1
0
 /**
  * Test the ability to create a Gnip activity (with an XML document),
  * and compare against identical values in strings.
  *
  * @access    public
  * @param     void
  * @return    void
  */
 function testFromXml()
 {
     $xml = '<activity at="2008-07-02T11:16:16+00:00" action="upload" actor="sally" ' . 'regarding="blog_post" source="web" tags="trains,planes,automobiles" ' . 'to="bob" url="http://example.com"/>';
     $a = Services_Gnip_Activity::fromXML(new SimpleXMLElement($xml));
     $expected_tags = array("trains", "planes", "automobiles");
     $this->assertEquals("2008-07-02T11:16:16+00:00", $a->at->format(DATE_ATOM));
     $this->assertEquals("upload", $a->action);
     $this->assertEquals("sally", $a->actor);
     $this->assertEquals("blog_post", $a->regarding);
     $this->assertEquals("web", $a->source);
     $this->assertEquals($expected_tags, $a->tags);
     $this->assertEquals("http://example.com", $a->url);
 }
Exemple #2
0
 /**
  * Parse an XML stream containing publisher or filter activities.
  *
  * @access    private
  * @param     string       $xml          contains xml to be parsed
  * @return    array                      publisher or filter activites
  */
 private function parseActivities($xml)
 {
     $xml = new SimpleXMLElement($xml);
     $activities = array();
     foreach ($xml->children() as $child) {
         $activities[] = Services_Gnip_Activity::fromXML($child);
     }
     return $activities;
 }
 function testFromXMLWithPayloadUnboundMediaURL()
 {
     $xml = '<activity>' . '<at>2008-07-02T11:16:16+00:00</at>' . '<action>post</action>' . '<payload><title>title</title><body>body</body><mediaURL type="image" mimeType="image/png">http://www.flickr.com/tour</mediaURL><mediaURL type="movie" mimeType="video/quicktime">http://www.gnipcentral.com/login</mediaURL><raw>H4sIAAAAAAAAAytKLAcAVduzGgMAAAA=</raw></payload>' . '</activity>';
     $a = Services_Gnip_Activity::fromXML($xml);
     $this->assertEquals($this->at, $a->at->format(DATE_ATOM));
     $this->assertEquals($this->action, $a->action);
     $this->assertEquals($this->payloadArray, $a->payload);
 }