H-OnlineComAtom10Test.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Feed
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once 'PHPUnit/Framework/TestCase.php';
  23. require_once 'Zend/Feed/Reader.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Feed
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Feed
  31. * @group Zend_Feed_Reader
  32. */
  33. class Zend_Feed_Reader_Integration_HOnlineComAtom10Test extends PHPUnit_Framework_TestCase
  34. {
  35. protected $_feedSamplePath = null;
  36. public function setup()
  37. {
  38. $this->_feedSamplePath = dirname(__FILE__) . '/_files/h-online.com-atom10.xml';
  39. }
  40. public function testGetsTitle()
  41. {
  42. $feed = Zend_Feed_Reader::importString(
  43. file_get_contents($this->_feedSamplePath)
  44. );
  45. $this->assertEquals('The H - news feed', $feed->getTitle());
  46. }
  47. public function testGetsAuthors()
  48. {
  49. $feed = Zend_Feed_Reader::importString(
  50. file_get_contents($this->_feedSamplePath)
  51. );
  52. $this->assertEquals(array('The H'), $feed->getAuthors());
  53. }
  54. public function testGetsSingleAuthor()
  55. {
  56. $feed = Zend_Feed_Reader::importString(
  57. file_get_contents($this->_feedSamplePath)
  58. );
  59. $this->assertEquals('The H', $feed->getAuthor());
  60. }
  61. public function testGetsCopyright()
  62. {
  63. $feed = Zend_Feed_Reader::importString(
  64. file_get_contents($this->_feedSamplePath)
  65. );
  66. $this->assertEquals(null, $feed->getCopyright());
  67. }
  68. public function testGetsDescription()
  69. {
  70. $feed = Zend_Feed_Reader::importString(
  71. file_get_contents($this->_feedSamplePath)
  72. );
  73. $this->assertEquals('Technology news', $feed->getDescription());
  74. }
  75. public function testGetsLanguage()
  76. {
  77. $feed = Zend_Feed_Reader::importString(
  78. file_get_contents($this->_feedSamplePath)
  79. );
  80. $this->assertEquals(null, $feed->getLanguage());
  81. }
  82. public function testGetsLink()
  83. {
  84. $feed = Zend_Feed_Reader::importString(
  85. file_get_contents($this->_feedSamplePath)
  86. );
  87. $this->assertEquals('http://www.h-online.com', $feed->getLink());
  88. }
  89. public function testGetsEncoding()
  90. {
  91. $feed = Zend_Feed_Reader::importString(
  92. file_get_contents($this->_feedSamplePath)
  93. );
  94. $this->assertEquals('UTF-8', $feed->getEncoding());
  95. }
  96. public function testGetsEntryCount()
  97. {
  98. $feed = Zend_Feed_Reader::importString(
  99. file_get_contents($this->_feedSamplePath)
  100. );
  101. $this->assertEquals(60, $feed->count());
  102. }
  103. /**
  104. * Entry level testing
  105. */
  106. public function testGetsEntryId()
  107. {
  108. $feed = Zend_Feed_Reader::importString(
  109. file_get_contents($this->_feedSamplePath)
  110. );
  111. $entry = $feed->current();
  112. $this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss', $entry->getId());
  113. }
  114. public function testGetsEntryTitle()
  115. {
  116. $feed = Zend_Feed_Reader::importString(
  117. file_get_contents($this->_feedSamplePath)
  118. );
  119. $entry = $feed->current();
  120. $this->assertEquals('McAfee update brings systems down again', $entry->getTitle());
  121. }
  122. public function testGetsEntryAuthors()
  123. {
  124. $feed = Zend_Feed_Reader::importString(
  125. file_get_contents($this->_feedSamplePath)
  126. );
  127. $entry = $feed->current();
  128. $this->assertEquals(array('The H'), $entry->getAuthors());
  129. }
  130. public function testGetsEntrySingleAuthor()
  131. {
  132. $feed = Zend_Feed_Reader::importString(
  133. file_get_contents($this->_feedSamplePath)
  134. );
  135. $entry = $feed->current();
  136. $this->assertEquals('The H', $entry->getAuthor());
  137. }
  138. public function testGetsEntryDescription()
  139. {
  140. $feed = Zend_Feed_Reader::importString(
  141. file_get_contents($this->_feedSamplePath)
  142. );
  143. $entry = $feed->current();
  144. /**
  145. * Note: "’" is not the same as "'" - don't replace in error
  146. */
  147. $this->assertEquals('A McAfee signature update is currently causing system failures and a lot of overtime for administrators', $entry->getDescription());
  148. }
  149. public function testGetsEntryContent()
  150. {
  151. $feed = Zend_Feed_Reader::importString(
  152. file_get_contents($this->_feedSamplePath)
  153. );
  154. $entry = $feed->current();
  155. $this->assertEquals('A McAfee signature update is currently causing system failures and a lot of overtime for administrators', $entry->getContent());
  156. }
  157. public function testGetsEntryLinks()
  158. {
  159. $feed = Zend_Feed_Reader::importString(
  160. file_get_contents($this->_feedSamplePath)
  161. );
  162. $entry = $feed->current();
  163. $this->assertEquals(array('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss'), $entry->getLinks());
  164. }
  165. public function testGetsEntryLink()
  166. {
  167. $feed = Zend_Feed_Reader::importString(
  168. file_get_contents($this->_feedSamplePath)
  169. );
  170. $entry = $feed->current();
  171. $this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss', $entry->getLink());
  172. }
  173. public function testGetsEntryPermaLink()
  174. {
  175. $feed = Zend_Feed_Reader::importString(
  176. file_get_contents($this->_feedSamplePath)
  177. );
  178. $entry = $feed->current();
  179. $this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss',
  180. $entry->getPermaLink());
  181. }
  182. public function testGetsEntryEncoding()
  183. {
  184. $feed = Zend_Feed_Reader::importString(
  185. file_get_contents($this->_feedSamplePath)
  186. );
  187. $entry = $feed->current();
  188. $this->assertEquals('UTF-8', $entry->getEncoding());
  189. }
  190. }