H-OnlineComAtom10Test.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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-2010 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-2010 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. Zend_Feed_Reader::reset();
  39. $this->_feedSamplePath = dirname(__FILE__) . '/_files/h-online.com-atom10.xml';
  40. $this->_options = Zend_Date::setOptions();
  41. foreach($this->_options as $k=>$v) {
  42. if (is_null($v)) {
  43. unset($this->_options[$k]);
  44. }
  45. }
  46. Zend_Date::setOptions(array('format_type'=>'iso'));
  47. }
  48. public function teardown()
  49. {
  50. Zend_Date::setOptions($this->_options);
  51. }
  52. public function testGetsTitle()
  53. {
  54. $feed = Zend_Feed_Reader::importString(
  55. file_get_contents($this->_feedSamplePath)
  56. );
  57. $this->assertEquals('The H - news feed', $feed->getTitle());
  58. }
  59. public function testGetsAuthors()
  60. {
  61. $feed = Zend_Feed_Reader::importString(
  62. file_get_contents($this->_feedSamplePath)
  63. );
  64. $this->assertEquals(array(array('name'=>'The H')), (array) $feed->getAuthors());
  65. }
  66. public function testGetsSingleAuthor()
  67. {
  68. $feed = Zend_Feed_Reader::importString(
  69. file_get_contents($this->_feedSamplePath)
  70. );
  71. $this->assertEquals(array('name'=>'The H'), $feed->getAuthor());
  72. }
  73. public function testGetsCopyright()
  74. {
  75. $feed = Zend_Feed_Reader::importString(
  76. file_get_contents($this->_feedSamplePath)
  77. );
  78. $this->assertEquals(null, $feed->getCopyright());
  79. }
  80. public function testGetsDescription()
  81. {
  82. $feed = Zend_Feed_Reader::importString(
  83. file_get_contents($this->_feedSamplePath)
  84. );
  85. $this->assertEquals('Technology news', $feed->getDescription());
  86. }
  87. public function testGetsLanguage()
  88. {
  89. $feed = Zend_Feed_Reader::importString(
  90. file_get_contents($this->_feedSamplePath)
  91. );
  92. $this->assertEquals(null, $feed->getLanguage());
  93. }
  94. public function testGetsLink()
  95. {
  96. $feed = Zend_Feed_Reader::importString(
  97. file_get_contents($this->_feedSamplePath)
  98. );
  99. $this->assertEquals('http://www.h-online.com', $feed->getLink());
  100. }
  101. public function testGetsEncoding()
  102. {
  103. $feed = Zend_Feed_Reader::importString(
  104. file_get_contents($this->_feedSamplePath)
  105. );
  106. $this->assertEquals('UTF-8', $feed->getEncoding());
  107. }
  108. public function testGetsEntryCount()
  109. {
  110. $feed = Zend_Feed_Reader::importString(
  111. file_get_contents($this->_feedSamplePath)
  112. );
  113. $this->assertEquals(60, $feed->count());
  114. }
  115. /**
  116. * Entry level testing
  117. */
  118. public function testGetsEntryId()
  119. {
  120. $feed = Zend_Feed_Reader::importString(
  121. file_get_contents($this->_feedSamplePath)
  122. );
  123. $entry = $feed->current();
  124. $this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss', $entry->getId());
  125. }
  126. public function testGetsEntryTitle()
  127. {
  128. $feed = Zend_Feed_Reader::importString(
  129. file_get_contents($this->_feedSamplePath)
  130. );
  131. $entry = $feed->current();
  132. $this->assertEquals('McAfee update brings systems down again', $entry->getTitle());
  133. }
  134. public function testGetsEntryAuthors()
  135. {
  136. $feed = Zend_Feed_Reader::importString(
  137. file_get_contents($this->_feedSamplePath)
  138. );
  139. $entry = $feed->current();
  140. $this->assertEquals(array(array('name'=>'The H')), (array) $entry->getAuthors());
  141. }
  142. public function testGetsEntrySingleAuthor()
  143. {
  144. $feed = Zend_Feed_Reader::importString(
  145. file_get_contents($this->_feedSamplePath)
  146. );
  147. $entry = $feed->current();
  148. $this->assertEquals(array('name'=>'The H'), $entry->getAuthor());
  149. }
  150. public function testGetsEntryDescription()
  151. {
  152. $feed = Zend_Feed_Reader::importString(
  153. file_get_contents($this->_feedSamplePath)
  154. );
  155. $entry = $feed->current();
  156. /**
  157. * Note: "’" is not the same as "'" - don't replace in error
  158. */
  159. $this->assertEquals('A McAfee signature update is currently causing system failures and a lot of overtime for administrators', $entry->getDescription());
  160. }
  161. public function testGetsEntryContent()
  162. {
  163. $feed = Zend_Feed_Reader::importString(
  164. file_get_contents($this->_feedSamplePath)
  165. );
  166. $entry = $feed->current();
  167. $this->assertEquals('A McAfee signature update is currently causing system failures and a lot of overtime for administrators', $entry->getContent());
  168. }
  169. public function testGetsEntryLinks()
  170. {
  171. $feed = Zend_Feed_Reader::importString(
  172. file_get_contents($this->_feedSamplePath)
  173. );
  174. $entry = $feed->current();
  175. $this->assertEquals(array('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss'), $entry->getLinks());
  176. }
  177. public function testGetsEntryLink()
  178. {
  179. $feed = Zend_Feed_Reader::importString(
  180. file_get_contents($this->_feedSamplePath)
  181. );
  182. $entry = $feed->current();
  183. $this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss', $entry->getLink());
  184. }
  185. public function testGetsEntryPermaLink()
  186. {
  187. $feed = Zend_Feed_Reader::importString(
  188. file_get_contents($this->_feedSamplePath)
  189. );
  190. $entry = $feed->current();
  191. $this->assertEquals('http://www.h-online.com/security/McAfee-update-brings-systems-down-again--/news/113689/from/rss',
  192. $entry->getPermaLink());
  193. }
  194. public function testGetsEntryEncoding()
  195. {
  196. $feed = Zend_Feed_Reader::importString(
  197. file_get_contents($this->_feedSamplePath)
  198. );
  199. $entry = $feed->current();
  200. $this->assertEquals('UTF-8', $entry->getEncoding());
  201. }
  202. }