Browse Source

Zend_Feed_Reader: completed (two errors remaining) unit tests over support API for Atom 1.0 source elements

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19287 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic 16 years ago
parent
commit
98dbce0608

+ 28 - 50
tests/Zend/Feed/Reader/Feed/AtomSourceTest.php

@@ -124,6 +124,7 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/author/atom10.xml')
         );
+        $source = $feed->current()->getSource();
 
         $authors = array(
             0 => 'joe@example.com (Joe Bloggs)',
@@ -133,7 +134,7 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
             6 => 'jane@example.com (Jane Bloggs)'
         );
 
-        $this->assertEquals($authors, $feed->getAuthors());
+        $this->assertEquals($authors, $source->getAuthors());
     }
 
     /**
@@ -145,8 +146,9 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/author/atom10.xml')
         );
+        $source = $feed->current()->getSource();
 
-        $this->assertEquals('joe@example.com (Joe Bloggs)', $feed->getAuthor());
+        $this->assertEquals('joe@example.com (Joe Bloggs)', $source->getAuthor());
     }
 
     /**
@@ -158,10 +160,11 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath . '/datecreated/atom10.xml')
         );
+        $source = $feed->current()->getSource();
 
         $edate = new Zend_Date;
         $edate->set('2009-03-07T08:03:50Z', Zend_Date::ISO_8601);
-        $this->assertTrue($edate->equals($feed->getDateCreated()));
+        $this->assertTrue($edate->equals($source->getDateCreated()));
     }
 
     /**
@@ -173,10 +176,11 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath . '/datemodified/atom10.xml')
         );
+        $source = $feed->current()->getSource();
 
         $edate = new Zend_Date;
         $edate->set('2009-03-07T08:03:50Z', Zend_Date::ISO_8601);
-        $this->assertTrue($edate->equals($feed->getDateModified()));
+        $this->assertTrue($edate->equals($source->getDateModified()));
     }
 
     /**
@@ -188,7 +192,8 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/generator/atom10.xml')
         );
-        $this->assertEquals('Zend_Feed', $feed->getGenerator());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('Zend_Feed', $source->getGenerator());
     }
 
     /**
@@ -200,7 +205,8 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/copyright/atom10.xml')
         );
-        $this->assertEquals('Copyright 2008', $feed->getCopyright());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('Copyright 2008', $source->getCopyright());
     }
 
     /**
@@ -212,7 +218,8 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/description/atom10.xml')
         );
-        $this->assertEquals('My Description', $feed->getDescription());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('My Description', $source->getDescription());
     }
 
     /**
@@ -224,7 +231,8 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/id/atom10.xml')
         );
-        $this->assertEquals('123', $feed->getId());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('123', $source->getId());
     }
 
     /**
@@ -236,7 +244,8 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/language/atom10.xml')
         );
-        $this->assertEquals('en-GB', $feed->getLanguage());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('en-GB', $source->getLanguage());
     }
 
     /**
@@ -248,34 +257,8 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/link/atom10.xml')
         );
-        $this->assertEquals('http://www.example.com', $feed->getLink());
-    }
-
-    public function testGetsLinkFromAtom10WithNoRelAttribute()
-    {
-        $feed = Zend_Feed_Reader::importString(
-            file_get_contents($this->_feedSamplePath.'/link/atom10-norel.xml')
-        );
-        $this->assertEquals('http://www.example.com', $feed->getLink());
-    }
-
-    public function testGetsLinkFromAtom10WithRelativeUrl()
-    {
-        $feed = Zend_Feed_Reader::importString(
-            file_get_contents($this->_feedSamplePath.'/link/atom10-relative.xml')
-        );
-        $this->assertEquals('http://www.example.com', $feed->getLink());
-    }
-
-    /**
-     * Get Base Uri
-     */
-    public function testGetsBaseUriFromAtom10()
-    {
-        $feed = Zend_Feed_Reader::importString(
-            file_get_contents($this->_feedSamplePath.'/feedlink/atom10-relative.xml')
-        );
-        $this->assertEquals('http://www.example.com/', $feed->getBaseUrl());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('http://www.example.com', $source->getLink());
     }
 
     /**
@@ -287,17 +270,10 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/feedlink/atom10.xml')
         );
-        $this->assertEquals('http://www.example.com/feed/atom', $feed->getFeedLink());
-    }
-
-    public function testGetsFeedLinkFromAtom10IfRelativeUri()
-    {
-        $feed = Zend_Feed_Reader::importString(
-            file_get_contents($this->_feedSamplePath.'/feedlink/atom10-relative.xml')
-        );
-        $this->assertEquals('http://www.example.com/feed/atom', $feed->getFeedLink());
+        $source = $feed->current()->getSource();
+        $this->assertEquals('http://www.example.com/feed/atom', $source->getFeedLink());
     }
-
+    
     /**
      * Get Pubsubhubbub Hubs
      */
@@ -307,10 +283,11 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/hubs/atom10.xml')
         );
+        $source = $feed->current()->getSource();
         $this->assertEquals(array(
             'http://www.example.com/hub1',
             'http://www.example.com/hub2'
-        ), $feed->getHubs());
+        ), $source->getHubs());
     }
     
     /**
@@ -322,8 +299,9 @@ class Zend_Feed_Reader_Feed_AtomSourceTest extends PHPUnit_Framework_TestCase
         $feed = Zend_Feed_Reader::importString(
             file_get_contents($this->_feedSamplePath.'/category/atom10.xml')
         );
-        $this->assertEquals($this->_expectedCats, (array) $feed->getCategories());
-        $this->assertEquals(array('topic1','Cat & Dog'), array_values($feed->getCategories()->getValues()));
+        $source = $feed->current()->getSource();
+        $this->assertEquals($this->_expectedCats, (array) $source->getCategories());
+        $this->assertEquals(array('topic1','Cat & Dog'), array_values($source->getCategories()->getValues()));
     }
 
 }

+ 47 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/author/atom10.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <author>
+                <name>Joe Bloggs</name>
+                <uri>http://www.example.com</uri>
+                <email>joe@example.com</email>
+            </author>
+            <author>
+                <name>Joe Bloggs</name>
+                <uri>http://www.example.com</uri>
+                <email></email>
+            </author>
+            <author>
+                <name>Joe Bloggs</name>
+                <uri></uri>
+                <email></email>
+            </author>
+            <author>
+                <name></name>
+                <uri>http://www.example.com</uri>
+                <email>joe@example.com</email>
+            </author>
+            <author>
+                <name></name>
+                <uri>http://www.example.com</uri>
+                <email></email>
+            </author>
+            <author>
+                <name></name>
+                <uri></uri>
+                <email>joe@example.com</email>
+            </author>
+            <author>
+                <name></name>
+                <uri></uri>
+                <email></email>
+            </author>
+            <contributor>
+                <name>Jane Bloggs</name>
+                <uri>http://www.example.com</uri>
+                <email>jane@example.com</email>
+            </contributor>
+        </source>
+    </entry>
+</feed>

+ 10 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/category/atom10.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <category scheme="http://example.com/schema1" term="topic1" label="topic1"/>
+            <category scheme="http://example.com/schema2" term="topic1" label="topic1"/>
+            <category scheme="http://example.com/schema1" term="cat_dog" label="Cat &amp; Dog"/>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/copyright/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <rights>Copyright 2008</rights>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/datecreated/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <published>2009-03-07T08:03:50Z</published>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/datemodified/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <updated>2009-03-07T08:03:50Z</updated>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/description/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <subtitle>My Description</subtitle>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/feedlink/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <link rel="self" type="application/atom+xml" href="http://www.example.com/feed/atom"/>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/generator/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <generator>Zend_Feed</generator>
+        </source>
+    </entry>
+</feed>

+ 9 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/hubs/atom10.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <link rel="hub" href="http://www.example.com/hub1"/>
+            <link rel="hub" href="http://www.example.com/hub2"/>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/id/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <id>123</id>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/language/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <lang>en-GB</lang>
+        </source>
+    </entry>
+</feed>

+ 8 - 0
tests/Zend/Feed/Reader/Feed/_files/AtomSource/link/atom10.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+    <entry>
+        <source>
+            <link href="http://www.example.com" rel="alternate"/>
+        </source>
+    </entry>
+</feed>