_feedSamplePath = dirname(__FILE__) . '/_files/wordpress-atom10.xml'; $this->_options = Zend_Date::setOptions(); foreach($this->_options as $k=>$v) { if (is_null($v)) { unset($this->_options[$k]); } } Zend_Date::setOptions(array('format_type'=>'iso')); } public function teardown() { Zend_Date::setOptions($this->_options); } public function testGetsTitle() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals('Norm 2782', $feed->getTitle()); } public function testGetsAuthors() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals(array( array('name'=>'norm2782','uri'=>'http://www.norm2782.com') ), (array) $feed->getAuthors()); } public function testGetsSingleAuthor() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals(array('name'=>'norm2782','uri'=>'http://www.norm2782.com'), $feed->getAuthor()); } public function testGetsCopyright() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals(null, $feed->getCopyright()); } public function testGetsDescription() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals('Why are you here?', $feed->getDescription()); } public function testGetsLanguage() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals('en', $feed->getLanguage()); } public function testGetsLink() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals('http://www.norm2782.com', $feed->getLink()); } public function testGetsEncoding() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals('UTF-8', $feed->getEncoding()); } public function testGetsEntryCount() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $this->assertEquals(10, $feed->count()); } /** * Entry level testing */ public function testGetsEntryId() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals('http://www.norm2782.com/?p=114', $entry->getId()); } public function testGetsEntryTitle() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); /** * Note: The three dots below is actually a single Unicode character * called the "three dot leader". Don't replace in error! */ $this->assertEquals('Wth… reading books?', $entry->getTitle()); } public function testGetsEntryAuthors() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals(array(array('name'=>'norm2782','uri'=>'http://www.norm2782.com')), (array) $entry->getAuthors()); } public function testGetsEntrySingleAuthor() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals(array('name'=>'norm2782','uri'=>'http://www.norm2782.com'), $entry->getAuthor()); } public function testGetsEntryDescription() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); /** * Note: "’" is not the same as "'" - don't replace in error */ $this->assertEquals('Being in New Zealand does strange things to a person. Everybody who knows me, knows I don’t much like that crazy invention called a Book. However, being here I’ve already finished 4 books, all of which I can highly recommend.'."\n\n".'Agile Software Development with Scrum, by Ken Schwaber and Mike Beedle'."\n".'Domain-Driven Design: Tackling Complexity in the [...]', $entry->getDescription()); } public function testGetsEntryContent() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals('
Being in New Zealand does strange things to a person. Everybody who knows me, knows I don’t much like that crazy invention called a Book. However, being here I’ve already finished 4 books, all of which I can highly recommend.
Next up: Design Patterns: Elements of Reusable Object-Oriented Software, by the Gang of Four. Yes, talk about classics and shame on me for not having ordered it sooner! Also reading Implementation Patterns, by Kent Beck at the moment.
', str_replace("\n",'',$entry->getContent())); } public function testGetsEntryLinks() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals(array('http://www.norm2782.com/2009/03/wth-reading-books/'), $entry->getLinks()); } public function testGetsEntryLink() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals('http://www.norm2782.com/2009/03/wth-reading-books/', $entry->getLink()); } public function testGetsEntryPermaLink() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals('http://www.norm2782.com/2009/03/wth-reading-books/', $entry->getPermaLink()); } public function testGetsEntryEncoding() { $feed = Zend_Feed_Reader::importString( file_get_contents($this->_feedSamplePath) ); $entry = $feed->current(); $this->assertEquals('UTF-8', $entry->getEncoding()); } }