mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-07-05 11:33:39 +00:00
[4.2 RC1] Feed display module not working (#38312)
This commit is contained in:
parent
6fde173e78
commit
aa1f62a006
|
@ -190,10 +190,9 @@ class AtomParser extends FeedParser
|
|||
*/
|
||||
protected function initialise()
|
||||
{
|
||||
// We want to move forward to the first XML Element after the xml doc type declaration
|
||||
$this->moveToNextElement();
|
||||
|
||||
// We are on the first XML Element after the xml doc type declaration
|
||||
$this->version = ($this->stream->getAttribute('version') == '0.3') ? '0.3' : '1.0';
|
||||
$this->moveToNextElement();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -347,10 +347,7 @@ class RssParser extends FeedParser
|
|||
*/
|
||||
protected function initialise()
|
||||
{
|
||||
// We want to move forward to the first XML Element after the xml doc type declaration
|
||||
$this->moveToNextElement();
|
||||
|
||||
// Read the version attribute.
|
||||
// We are on the first XML Element after the xml doc type declaration
|
||||
$this->version = $this->stream->getAttribute('version');
|
||||
|
||||
// We want to move forward to the first element after the <channel> element.
|
||||
|
|
|
@ -351,9 +351,26 @@ class AtomParserTest extends UnitTestCase
|
|||
*/
|
||||
public function testInitialiseSetsDefaultVersion()
|
||||
{
|
||||
$dummyXml = '<feed xmlns="http://www.w3.org/2005/Atom" />';
|
||||
$dummyXml = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- generator="Joomla! Unit Test" -->
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title type="text">Joomla! Unit test</title>
|
||||
</feed>';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$atomParser = new AtomParser($reader);
|
||||
|
||||
// same logic as FeedFactory.php : skip head record
|
||||
try {
|
||||
// Skip ahead to the root node.
|
||||
while ($reader->read()) {
|
||||
if ($reader->nodeType == \XMLReader::ELEMENT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException('Error reading feed.', $e->getCode(), $e);
|
||||
}
|
||||
|
||||
$atomParser->parse();
|
||||
|
||||
// Use reflection to check the value
|
||||
|
@ -373,9 +390,26 @@ class AtomParserTest extends UnitTestCase
|
|||
*/
|
||||
public function testInitialiseSetsOldVersion()
|
||||
{
|
||||
$dummyXml = '<feed version="0.3" xmlns="http://www.w3.org/2005/Atom" />';
|
||||
$dummyXml = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- generator="Joomla! Unit Test" -->
|
||||
<feed version="0.3" xmlns="http://www.w3.org/2005/Atom">
|
||||
<title type="text">Joomla! Unit test</title>
|
||||
</feed>';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$atomParser = new AtomParser($reader);
|
||||
|
||||
// same logic as FeedFactory.php : skip head record
|
||||
try {
|
||||
// Skip ahead to the root node.
|
||||
while ($reader->read()) {
|
||||
if ($reader->nodeType == \XMLReader::ELEMENT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException('Error reading feed.', $e->getCode(), $e);
|
||||
}
|
||||
|
||||
$atomParser->parse();
|
||||
|
||||
// Use reflection to check the value
|
||||
|
|
|
@ -583,6 +583,7 @@ class RssParserTest extends UnitTestCase
|
|||
public function testParseSetsVersion()
|
||||
{
|
||||
$dummyXml = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- generator="Joomla! Unit Test" -->
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>Test Channel</title>
|
||||
|
@ -590,13 +591,26 @@ class RssParserTest extends UnitTestCase
|
|||
</rss>';
|
||||
$reader = \XMLReader::XML($dummyXml);
|
||||
$rssParser = new RssParser($reader);
|
||||
|
||||
// same logic as FeedFactory.php : skip head record
|
||||
try {
|
||||
// Skip ahead to the root node.
|
||||
while ($reader->read()) {
|
||||
if ($reader->nodeType == \XMLReader::ELEMENT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException('Error reading feed.', $e->getCode(), $e);
|
||||
}
|
||||
|
||||
$rssParser->parse();
|
||||
|
||||
// Use reflection to check the value
|
||||
$reflectionClass = new ReflectionClass($rssParser);
|
||||
$attribute = $reflectionClass->getProperty('version');
|
||||
$attribute->setAccessible(true);
|
||||
|
||||
$attribute->setAccessible(true);
|
||||
$this->assertEquals('2.0', $attribute->getValue($rssParser));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user