public function testAddAuthorThrowsExceptionIfNameOmittedFromArray() { $entry = new Writer\Entry(); try { $entry->addAuthor(array('uri' => 'notauri')); $this->fail(); } catch (Writer\Exception\InvalidArgumentException $e) { } }
/** * Populates a feed entry with data coming from Version objects. * * @param \Zend\Feed\Writer\Entry $entry * @param Version $version */ protected function populateVersionData(Entry $entry, Version $version) { $entry->setTitle($entry->getTitle() . " ({$version->getVersion()})"); $entry->setId($entry->getId() . ' ' . $version->getVersion()); $entry->setDateModified($version->getReleasedAt()); $entry->setDateCreated($version->getReleasedAt()); foreach ($version->getAuthors() as $author) { /** @var $author \Packagist\WebBundle\Entity\Author */ if ($author->getName()) { $entry->addAuthor(array('name' => $author->getName())); } } }
public function testFluentInterface() { $entry = new Writer\Entry(); $result = $entry->addAuthor(array('name' => 'foo'))->addAuthors(array(array('name' => 'foo')))->setEncoding('utf-8')->setCopyright('copyright')->setContent('content')->setDateCreated(null)->setDateModified(null)->setDescription('description')->setId('1')->setLink('http://www.example.com')->setCommentCount(1)->setCommentLink('http://www.example.com')->setCommentFeedLink(array('uri' => 'http://www.example.com', 'type' => 'rss'))->setCommentFeedLinks(array(array('uri' => 'http://www.example.com', 'type' => 'rss')))->setTitle('title')->addCategory(array('term' => 'category'))->addCategories(array(array('term' => 'category')))->setEnclosure(array('uri' => 'http://www.example.com'))->setType('type')->setSource(new \Zend\Feed\Writer\Source()); $this->assertSame($result, $entry); }