Exemplo n.º 1
0
    public function testBuildMediaEntry()
    {
        $feed = new AtomFeedAdapter(null);
        $feed->addNamespace('m', MediaNS::NS);
        $entry = $feed->addEntry();
        $mediaEntry = $entry->getExtension(MediaNS::NS);
        $mediaEntry->description = 'this is the media description';
        $link = $entry->addLink();
        $mediaLink = $link->getExtension(MediaNS::NS);
        $mediaLink->rel = 'this is the media link rel';
        $mediaLink->href = 'this is the media link href';
        $mediaLink->type = 'this is the media link type';
        $mediaLink->width = 'this is the media link width';
        $mediaLink->width = 'this is the media link width';
        $mediaLink->height = 'this is the media link height';
        $mediaLink->duration = 'this is the media link duration';
        $expectedResult = '<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://purl.org/syndication/atommedia"><entry><m:description>this is the media description</m:description><link rel="this is the media link rel" href="this is the media link href" type="this is the media link type" m:width="this is the media link width" m:height="this is the media link height" m:duration="this is the media link duration"/></entry></feed>';
        $this->assertEquals(trim($feed->getXml()), trim($expectedResult));
        return $feed;
    }
Exemplo n.º 2
0
 /**
  * Returns a feed of comment of an item
  * 
  * @param array $comments
  * @param mixed $item
  * @return AtomFeedAdapter
  */
 public function buildCommentsFeed($comments, $item)
 {
     $application = Stuffpress_Application::getInstance();
     $feed = new AtomFeedAdapter(null);
     $feed->addNamespace(ActivityNS::PREFIX, ActivityNS::NS);
     $feed->title = "Comments of " . $this->_getObjectId($item);
     $feed->id = "http://" . $this->_domain . "/api/comments";
     //
     $feed->updated = toAtomDate(time());
     $feedLink = $feed->addLink();
     $feedLink->rel = 'self';
     $feedLink->href = 'http://' . $this->_domain . "/api/comments/" . $this->_getObjectId($item);
     foreach ($comments as $comment) {
         $this->buildCommentEntry(new Comment($comment), $item, $feed->addEntry());
     }
     return $feed;
 }
Exemplo n.º 3
0
    /**
     * @depends testBuildFeed
     */
    public function testBuildActivityFeed(AtomFeedAdapter $new)
    {
        $new->addNamespace('a', ActivityNS::NS);
        $newActivityEntry = $new->entry[0]->getExtension(ActivityNS::NS);
        $newActivityEntry->addVerb()->value = 'New Activity Entry Verb';
        $newActivityEntry->addObject()->addObjectType()->value = 'New Activity Entry Object Object Type';
        $newActivityEntry->object[0]->addLink()->duration = 'New Activity Entry Object Link Duration';
        $newActivityEntry->generator = 'New Activity Entry Generator';
        $newActivityEntry->generator->uri = 'New Activity Entry Generator Uri';
        $newActivityEntry->generator->version = 'New Activity Entry Generator Version';
        $newEntryActivityTarget = $newActivityEntry->addTarget();
        $newEntryActivityTarget->addObjectType()->value = 'New Activity Entry Target Object Type';
        $newEntryActivityTarget->id = 'New Activity Entry Target Id';
        $newEntryActivityTarget->title = 'New Activity Entry Target Title';
        $newEntryActivityTarget->addObjectType()->value = 'New Activity Entry Target Object Type';
        $newEntryActivityTargetLink = $newEntryActivityTarget->addLink();
        $newEntryActivityTargetLink->href = 'New Entry Activity Target Link Href';
        $newEntryActivityTargetLink->type = 'New Entry Activity Target Link Type';
        $newEntryActivityTargetLink->rel = 'New Entry Activity Target Link Rel';
        $newEntryActivityTargetLink->title = 'New Entry Activity Target Link Title';
        $newEntryActivityTargetLink->hreflang = 'New Entry Activity Target Link Hreflang';
        $newEntryActivityTargetLink->length = 'New Entry Activity Target Link Length';
        $newEntryActivityAuthor = $new->entry[0]->author[0]->getExtension(ActivityNS::NS);
        $newEntryActivityAuthor->addObjectType()->value = 'New Entry Activity Author Object Type';
        $newEntryActivityAuthor->id = 'New Entry Activity Author Id';
        $newEntryActivityAuthorLink = $newEntryActivityAuthor->addLink();
        $newEntryActivityAuthorLink->href = 'New Entry Activity Author Link Href';
        $newEntryActivityAuthorLink->type = 'New Entry Activity Author Link Type';
        $newEntryActivityAuthorLink->rel = 'New Entry Activity Author Link Rel';
        $newEntryActivityAuthorLink->title = 'New Entry Activity Author Link Title';
        $newEntryActivityAuthorLink->hreflang = 'New Entry Activity Author Link Hreflang';
        $newEntryActivityAuthorLink->length = 'New Entry Activity Author Link Length';
        $expectedResult = '<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:a="http://activitystrea.ms/spec/1.0/"><title type="New Title Type">New Title</title><id>New Id</id><updated>New Updated</updated><generator uri="New Generator Uri" version="New Generator Version">New Generator</generator><author><name>New Author Name</name><uri>New Author Uri</uri><email>New Author Email</email></author><link href="New Link Href" type="New Link Type" rel="New Link Rel" title="New Link Title" hreflang="New Link Hreflang" length="New Link Length"/><category term="New Category Term" scheme="New Category Scheme" label="New Category Label"/><entry><title type="New Entry Title Type">New Entry Title</title><id>New Entry Id</id><updated>New Entry Updated</updated><published>New Entry Published</published><summary type="New Entry Summary Type">New Entry Summary</summary><content type="New Entry Content Type" src="New Entry Content Src">New Entry Content</content><author><name>New Entry Author Name</name><uri>New Entry Author Uri</uri><email>New Entry Author Email</email><a:object-type>New Entry Activity Author Object Type</a:object-type><id>New Entry Activity Author Id</id><link href="New Entry Activity Author Link Href" type="New Entry Activity Author Link Type" rel="New Entry Activity Author Link Rel" title="New Entry Activity Author Link Title" hreflang="New Entry Activity Author Link Hreflang" length="New Entry Activity Author Link Length"/></author><link href="New Entry Link Href" type="New Entry Link Type" rel="New Entry Link Rel" title="New Entry Link Title" hreflang="New Entry Link Hreflang" length="New Entry Link Length"/><category term="New Entry Category Term" scheme="New Entry Category Scheme" label="New Entry Category Label"/><a:verb>New Activity Entry Verb</a:verb><a:object><a:object-type>New Activity Entry Object Object Type</a:object-type><link xmlns:media="http://purl.org/syndication/atommedia" media:duration="New Activity Entry Object Link Duration"/></a:object><generator uri="New Activity Entry Generator Uri" version="New Activity Entry Generator Version">New Activity Entry Generator</generator><a:target><a:object-type>New Activity Entry Target Object Type</a:object-type><id>New Activity Entry Target Id</id><title>New Activity Entry Target Title</title><a:object-type>New Activity Entry Target Object Type</a:object-type><link href="New Entry Activity Target Link Href" type="New Entry Activity Target Link Type" rel="New Entry Activity Target Link Rel" title="New Entry Activity Target Link Title" hreflang="New Entry Activity Target Link Hreflang" length="New Entry Activity Target Link Length"/></a:target></entry></feed>';
        $this->assertEquals(trim($new->getXml()), trim($expectedResult));
    }