Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: zendframework/zf2
base: 46ea6e9f54
...
head fork: zendframework/zf2
compare: f23b92b9cf
  • 5 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jul 04, 2012
Fritz Gerneth Added test for Entry detecting feed type if not given in constructor 77d1116
Fritz Gerneth Applied fix for previously failing test Zend\Feed\Reader\Entry\Common…
…Test::testFeedEntryCanDetectFeedType
c742061
Commits on Jul 05, 2012
Fritz Gerneth Merge remote-tracking branch 'remotes/zf2/master' into test/feed-entr…
…y-type-detection
18acdf2
Fritz Gerneth * AbstractEntry::__construct sets type to any if unable to detect type
* Added test for changed behavior of AbstractEntry::__construct
* Fixed spacing issues
d19d082
@weierophinney weierophinney Merge branch 'test/feed-entry-type-detection' of https://github.com/f…
…ritz-gerneth/zf2 into feature/feed-autodetect
f23b92b
View
4 library/Zend/Feed/Reader/Entry/AbstractEntry.php
@@ -91,8 +91,10 @@ public function __construct(DOMElement $entry, $entryKey, $type = null)
$this->_domDocument = $entry->ownerDocument;
if ($type !== null) {
$this->_data['type'] = $type;
+ } else if ($this->_domDocument !== null) {
+ $this->_data['type'] = Reader\Reader::detectType($this->_domDocument);
} else {
- $this->_data['type'] = Reader\Reader::detectType($feed);
+ $this->_data['type'] = Reader\Reader::TYPE_ANY;
}
$this->_loadExtensions();
}
View
33 tests/Zend/Feed/Reader/Entry/CommonTest.php
@@ -133,5 +133,36 @@ public function testReturnsEncodingOfFeedAsUtf8IfUndefined()
$this->assertEquals('UTF-8', $entry->getEncoding());
}
-
+ /**
+ * When not passing the optional argument type
+ */
+ public function testFeedEntryCanDetectFeedType()
+ {
+ $feed = Reader\Reader::importString(
+ file_get_contents($this->_feedSamplePath.'/atom.xml')
+ );
+ $entry = $feed->current();
+ $stub = $this->getMockForAbstractClass(
+ 'Zend\Feed\Reader\Entry\AbstractEntry',
+ array($entry->getElement(), $entry->getId())
+ );
+ $this->assertEquals($entry->getType(), $stub->getType());
+ }
+
+ /**
+ * When passing a newly created DOMElement without any DOMDocument assigned
+ */
+ public function testFeedEntryCanSetAnyType()
+ {
+ $feed = Reader\Reader::importString(
+ file_get_contents($this->_feedSamplePath.'/atom.xml')
+ );
+ $entry = $feed->current();
+ $domElement = new \DOMElement($entry->getElement()->tagName);
+ $stub = $this->getMockForAbstractClass(
+ 'Zend\Feed\Reader\Entry\AbstractEntry',
+ array($domElement, $entry->getId())
+ );
+ $this->assertEquals($stub->getType(), Reader\Reader::TYPE_ANY);
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.