Browse Source

Added URLs of feeds as keys to array from Zend_Feed::findFeeds() method - fixes ZF-5903

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18289 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic 16 years ago
parent
commit
5fd5785778
3 changed files with 35 additions and 1 deletions
  1. 1 1
      library/Zend/Feed.php
  2. 18 0
      tests/Zend/Feed/ImportTest.php
  3. 16 0
      tests/Zend/Feed/_files/htmlPage.html

+ 1 - 1
library/Zend/Feed.php

@@ -362,7 +362,7 @@ class Zend_Feed
                 } catch (Exception $e) {
                     continue;
                 }
-                $feeds[] = $feed;
+                $feeds[$uri->getUri()] = $feed;
             }
         }
 

+ 18 - 0
tests/Zend/Feed/ImportTest.php

@@ -441,4 +441,22 @@ class Zend_Feed_ImportTest extends PHPUnit_Framework_TestCase
             $this->assertType('Zend_Feed_Exception', $e);
         }
     }
+
+    /**
+     * @issue ZF-5903
+     */
+    public function testFindFeedsIncludesUriAsArrayKey()
+    {
+        if (!defined('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
+            || !constant('TESTS_ZEND_FEED_READER_ONLINE_ENABLED')
+        ) {
+            $this->markTestSkipped('testFindFeedsIncludesUriAsArrayKey() requires a network connection');
+            return;
+        }
+        Zend_Feed::setHttpClient(new Zend_Http_Client);
+        $feeds = Zend_Feed::findFeeds('http://www.planet-php.net');
+        $this->assertEquals(array(
+            'http://www.planet-php.org:80/rss/', 'http://www.planet-php.org:80/rdf/'
+        ), array_keys($feeds));
+    }
 }

+ 16 - 0
tests/Zend/Feed/_files/htmlPage.html

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <title>
+   Blog
+  </title>
+  <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.planet-php.org/rss/" />
+  <link rel="alternate" type="application/rdf+xml" title="RDF" href="http://www.planet-php.org/rdf/" />
+  <link rel="alternate" type="application/x.atom+xml" title="Atom" href="http://www.planet-php.org/atom/" />
+ </head>
+ <body>
+ </body>
+</html>