CommonTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. require_once 'PHPUnit/Framework/TestCase.php';
  3. require_once 'Zend/Feed/Reader.php';
  4. class Zend_Feed_Reader_Feed_CommonTest extends PHPUnit_Framework_TestCase
  5. {
  6. protected $_feedSamplePath = null;
  7. public function setup()
  8. {
  9. if (Zend_Registry::isRegistered('Zend_Locale')) {
  10. $registry = Zend_Registry::getInstance();
  11. unset($registry['Zend_Locale']);
  12. }
  13. $this->_feedSamplePath = dirname(__FILE__) . '/_files/Common';
  14. }
  15. /**
  16. * Check DOM Retrieval and Information Methods
  17. */
  18. public function testGetsDomDocumentObject()
  19. {
  20. $feed = Zend_Feed_Reader::importString(
  21. file_get_contents($this->_feedSamplePath.'/atom.xml')
  22. );
  23. $this->assertTrue($feed->getDomDocument() instanceof DOMDocument);
  24. }
  25. public function testGetsDomXpathObject()
  26. {
  27. $feed = Zend_Feed_Reader::importString(
  28. file_get_contents($this->_feedSamplePath.'/atom.xml')
  29. );
  30. $this->assertTrue($feed->getXpath() instanceof DOMXPath);
  31. }
  32. public function testGetsXpathPrefixString()
  33. {
  34. $feed = Zend_Feed_Reader::importString(
  35. file_get_contents($this->_feedSamplePath.'/atom.xml')
  36. );
  37. $this->assertTrue($feed->getXpathPrefix() == '/atom:feed');
  38. }
  39. public function testGetsDomElementObject()
  40. {
  41. $feed = Zend_Feed_Reader::importString(
  42. file_get_contents($this->_feedSamplePath.'/atom.xml')
  43. );
  44. $this->assertTrue($feed->getElement() instanceof DOMElement);
  45. }
  46. public function testSaveXmlOutputsXmlStringForFeed()
  47. {
  48. $feed = Zend_Feed_Reader::importString(
  49. file_get_contents($this->_feedSamplePath.'/atom.xml')
  50. );
  51. $this->assertEquals($feed->saveXml(), file_get_contents($this->_feedSamplePath.'/atom_rewrittenbydom.xml'));
  52. }
  53. }