public function testWriter() { $writer = new Writer('Liftoff News', 'http://liftoff.msfc.nasa.gov/', 'Liftoff to Space Exploration.'); $writer->setLanguage('en-us'); $writer->setPubDate(new DateTime('Tue, 10 Jun 2003 04:00:00 GMT')); $writer->setLastBuildDate(new DateTime('Tue, 10 Jun 2003 09:41:01 GMT')); $writer->setDocs('http://blogs.law.harvard.edu/tech/rss'); $writer->setGenerator('Weblog Editor 2.0'); $writer->setManagingEditor('*****@*****.**'); $writer->setWebMaster('*****@*****.**'); $item = $writer->createItem(); $item->setTitle('Star City'); $item->setLink('http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp'); $item->setDescription('How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia\'s <a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm">Star City</a>.'); $item->setPubDate(new DateTime('Tue, 03 Jun 2003 09:39:21 GMT')); $item->setGuid('http://liftoff.msfc.nasa.gov/2003/06/03.html#item573'); $item->close(); $actual = $writer->toString(); $expected = <<<XML <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> \t<channel> \t\t<title>Liftoff News</title> \t\t<link>http://liftoff.msfc.nasa.gov/</link> \t\t<description>Liftoff to Space Exploration.</description> \t\t<language>en-us</language> \t\t<pubDate>Tue, 10 Jun 2003 04:00:00 +0000</pubDate> \t\t<lastBuildDate>Tue, 10 Jun 2003 09:41:01 +0000</lastBuildDate> \t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs> \t\t<generator>Weblog Editor 2.0</generator> \t\t<managingEditor>editor@example.com</managingEditor> \t\t<webMaster>webmaster@example.com</webMaster> \t\t<item> \t\t\t<title>Star City</title> \t\t\t<link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link> \t\t\t<description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's <a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm">Star City</a>.</description> \t\t\t<pubDate>Tue, 03 Jun 2003 09:39:21 +0000</pubDate> \t\t\t<guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid> \t\t</item> \t</channel> </rss> XML; $this->assertXmlStringEqualsXmlString($expected, $actual); }
protected function buildChannel(RssRecord $rss, Writer $writer) { $language = $rss->getLanguage(); if (!empty($language)) { $writer->setLanguage($language); } $copyright = $rss->getCopyright(); if (!empty($copyright)) { $writer->setCopyright($copyright); } $managingEditor = $rss->getManagingEditor(); if (!empty($managingEditor)) { $writer->setManagingEditor($managingEditor); } $webMaster = $rss->getWebMaster(); if (!empty($webMaster)) { $writer->setWebMaster($webMaster); } $pubDate = $rss->getPubDate(); if ($pubDate instanceof DateTime) { $writer->setPubDate($pubDate); } $lastBuildDate = $rss->getLastBuildDate(); if ($lastBuildDate instanceof DateTime) { $writer->setLastBuildDate($lastBuildDate); } $categories = $rss->getCategory(); if (is_array($categories)) { foreach ($categories as $category) { $writer->addCategory($category->getText(), $category->getDomain()); } } $generator = $rss->getGenerator(); if (!empty($generator)) { $writer->setGenerator($generator); } $docs = $rss->getDocs(); if (!empty($docs)) { $writer->setDocs($docs); } $cloud = $rss->getCloud(); if ($cloud instanceof Cloud) { $writer->setCloud($cloud->getDomain(), $cloud->getPort(), $cloud->getPath(), $cloud->getRegisterProcedure(), $cloud->getProtocol()); } $ttl = $rss->getTtl(); if (!empty($ttl)) { $writer->setTtl($ttl); } $rating = $rss->getRating(); if (!empty($rating)) { $writer->setRating($rating); } $skipHours = $rss->getSkipHours(); if (!empty($skipHours)) { $writer->setSkipHours($skipHours); } $skipDays = $rss->getSkipDays(); if (!empty($skipDays)) { $writer->setSkipDays($skipDays); } }