/ZendFramework/tests/Zend/Feed/Reader/Integration/H-OnlineComAtom10Test.php

https://bitbucket.org/Dal-Papa/is-340-publish-base · PHP · 227 lines · 166 code · 26 blank · 35 comment · 1 complexity · c79668e7575e884e5855235004cd1b9b MD5 · raw file

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