| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <?php
- require_once 'PHPUnit/Framework/TestCase.php';
- require_once 'Zend/Feed/Reader.php';
- class Zend_Feed_Reader_Feed_AtomTest extends PHPUnit_Framework_TestCase
- {
- protected $_feedSamplePath = null;
- public function setup()
- {
- if (Zend_Registry::isRegistered('Zend_Locale')) {
- $registry = Zend_Registry::getInstance();
- unset($registry['Zend_Locale']);
- }
- $this->_feedSamplePath = dirname(__FILE__) . '/_files/Atom';
- }
- /**
- * Get Title (Unencoded Text)
- */
- public function testGetsTitleFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/title/plain/atom03.xml')
- );
- $this->assertEquals('My Title', $feed->getTitle());
- }
- public function testGetsTitleFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/title/plain/atom10.xml')
- );
- $this->assertEquals('My Title', $feed->getTitle());
- }
- /**
- * Get Authors (Unencoded Text)
- */
- public function testGetsAuthorArrayFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/author/plain/atom03.xml')
- );
- $authors = array(
- 0 => 'joe@example.com (Joe Bloggs)',
- 1 => 'Joe Bloggs',
- 3 => 'joe@example.com',
- 4 => 'http://www.example.com',
- 6 => 'jane@example.com (Jane Bloggs)'
- );
- $this->assertEquals($authors, $feed->getAuthors());
- }
- public function testGetsAuthorArrayFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/author/plain/atom10.xml')
- );
- $authors = array(
- 0 => 'joe@example.com (Joe Bloggs)',
- 1 => 'Joe Bloggs',
- 3 => 'joe@example.com',
- 4 => 'http://www.example.com',
- 6 => 'jane@example.com (Jane Bloggs)'
- );
- $this->assertEquals($authors, $feed->getAuthors());
- }
- /**
- * Get Single Author (Unencoded Text)
- */
- public function testGetsSingleAuthorFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/author/plain/atom03.xml')
- );
- $this->assertEquals('joe@example.com (Joe Bloggs)', $feed->getAuthor());
- }
- public function testGetsSingleAuthorFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/author/plain/atom10.xml')
- );
- $this->assertEquals('joe@example.com (Joe Bloggs)', $feed->getAuthor());
- }
- /**
- * Get creation date (Unencoded Text)
- */
- public function testGetsDateCreatedFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath . '/datecreated/plain/atom03.xml')
- );
- $this->assertEquals('Saturday 07 March 2009 08 03 50 +0000',
- $feed->getDateCreated()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
- }
- public function testGetsDateCreatedFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath . '/datecreated/plain/atom10.xml')
- );
- $this->assertEquals('Saturday 07 March 2009 08 03 50 +0000',
- $feed->getDateCreated()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
- }
- /**
- * Get modification date (Unencoded Text)
- */
- public function testGetsDateModifiedFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath . '/datemodified/plain/atom03.xml')
- );
- $this->assertEquals('Saturday 07 March 2009 08 03 50 +0000',
- $feed->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
- }
- public function testGetsDateModifiedFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath . '/datemodified/plain/atom10.xml')
- );
- $this->assertEquals('Saturday 07 March 2009 08 03 50 +0000',
- $feed->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ'));
- }
- /**
- * Get Generator (Unencoded Text)
- */
- public function testGetsGeneratorFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/generator/plain/atom03.xml')
- );
- $this->assertEquals('Zend_Feed', $feed->getGenerator());
- }
- public function testGetsGeneratorFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/generator/plain/atom10.xml')
- );
- $this->assertEquals('Zend_Feed', $feed->getGenerator());
- }
- /**
- * Get Copyright (Unencoded Text)
- */
- public function testGetsCopyrightFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/copyright/plain/atom03.xml')
- );
- $this->assertEquals('Copyright 2008', $feed->getCopyright());
- }
- public function testGetsCopyrightFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/copyright/plain/atom10.xml')
- );
- $this->assertEquals('Copyright 2008', $feed->getCopyright());
- }
- /**
- * Get Description (Unencoded Text)
- */
- public function testGetsDescriptionFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/description/plain/atom03.xml')
- );
- $this->assertEquals('My Description', $feed->getDescription());
- }
- public function testGetsDescriptionFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/description/plain/atom10.xml')
- );
- $this->assertEquals('My Description', $feed->getDescription());
- }
- /**
- * Get Id (Unencoded Text)
- */
- public function testGetsIdFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/id/plain/atom03.xml')
- );
- $this->assertEquals('123', $feed->getId());
- }
- public function testGetsIdFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/id/plain/atom10.xml')
- );
- $this->assertEquals('123', $feed->getId());
- }
- /**
- * Get Language (Unencoded Text)
- */
- public function testGetsLanguageFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/language/plain/atom03.xml')
- );
- $this->assertEquals('en-GB', $feed->getLanguage());
- }
- public function testGetsLanguageFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/language/plain/atom10.xml')
- );
- $this->assertEquals('en-GB', $feed->getLanguage());
- }
- /**
- * Get Link (Unencoded Text)
- */
- public function testGetsLinkFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/link/plain/atom03.xml')
- );
- $this->assertEquals('http://www.example.com', $feed->getLink());
- }
- public function testGetsLinkFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/link/plain/atom10.xml')
- );
- $this->assertEquals('http://www.example.com', $feed->getLink());
- }
- /**
- * Get Feed Link (Unencoded Text)
- */
- public function testGetsFeedLinkFromAtom03()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/feedlink/plain/atom03.xml')
- );
- $this->assertEquals('http://www.example.com/feed/atom', $feed->getFeedLink());
- }
- public function testGetsFeedLinkFromAtom10()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/feedlink/plain/atom10.xml')
- );
- $this->assertEquals('http://www.example.com/feed/atom', $feed->getFeedLink());
- }
- /**
- * Implements Countable
- */
- public function testCountableInterface()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/link/plain/atom10.xml')
- );
- $this->assertEquals(0, count($feed));
- }
- }
|