| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Feed
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- require_once 'Zend/Feed/Reader.php';
- /**
- * @category Zend
- * @package Zend_Feed
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Feed
- * @group Zend_Feed_Reader
- */
- class Zend_Feed_Reader_Entry_CommonTest extends PHPUnit_Framework_TestCase
- {
- protected $_feedSamplePath = null;
- public function setup()
- {
- Zend_Feed_Reader::reset();
- if (Zend_Registry::isRegistered('Zend_Locale')) {
- $registry = Zend_Registry::getInstance();
- unset($registry['Zend_Locale']);
- }
- $this->_feedSamplePath = dirname(__FILE__) . '/_files/Common';
- }
- /**
- * Check DOM Retrieval and Information Methods
- */
- public function testGetsDomDocumentObject()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertTrue($entry->getDomDocument() instanceof DOMDocument);
- }
- public function testGetsDomXpathObject()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertTrue($entry->getXpath() instanceof DOMXPath);
- }
- public function testGetsXpathPrefixString()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertEquals('//atom:entry[1]', $entry->getXpathPrefix());
- }
- public function testGetsDomElementObject()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertTrue($entry->getElement() instanceof DOMElement);
- }
- public function testSaveXmlOutputsXmlStringForEntry()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertEquals($entry->saveXml(), file_get_contents($this->_feedSamplePath.'/atom_rewrittenbydom.xml'));
- }
- public function testGetsNamedExtension()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertTrue($entry->getExtension('Atom') instanceof Zend_Feed_Reader_Extension_Atom_Entry);
- }
- public function testReturnsNullIfExtensionDoesNotExist()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertEquals(null, $entry->getExtension('Foo'));
- }
-
- /**
- * @group ZF-8213
- */
- public function testReturnsEncodingOfFeed()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom.xml')
- );
- $entry = $feed->current();
- $this->assertEquals('UTF-8', $entry->getEncoding());
- }
-
- /**
- * @group ZF-8213
- */
- public function testReturnsEncodingOfFeedAsUtf8IfUndefined()
- {
- $feed = Zend_Feed_Reader::importString(
- file_get_contents($this->_feedSamplePath.'/atom_noencodingdefined.xml')
- );
- $entry = $feed->current();
- $this->assertEquals('UTF-8', $entry->getEncoding());
- }
- }
|