Author: as
Date: Thu Oct 11 15:22:54 2007
New Revision: 6421

Log:
- The addModule() method in ezcFeed now accepts the name of a module instead
  the name of a class.

Modified:
    trunk/Feed/ChangeLog
    trunk/Feed/docs/tutorial.txt
    trunk/Feed/src/feed.php
    trunk/Feed/src/processors/rss2.php
    trunk/Feed/tests/feed_test.php
    trunk/Feed/tests/rss2/rss2_test.php

Modified: trunk/Feed/ChangeLog
==============================================================================
--- trunk/Feed/ChangeLog [iso-8859-1] (original)
+++ trunk/Feed/ChangeLog [iso-8859-1] Thu Oct 11 15:22:54 2007
@@ -4,6 +4,8 @@
 - In RSS2 the title, link and description nodes of item nodes are not all
   required, but at least one of title or description nodes is required.
 - The RSS2 image node is created and parsed correctly.
+- The addModule() method in ezcFeed now accepts the name of a module instead
+  the name of a class.
 
 
 1.0beta1 - Monday 18 December 2006

Modified: trunk/Feed/docs/tutorial.txt
==============================================================================
--- trunk/Feed/docs/tutorial.txt [iso-8859-1] (original)
+++ trunk/Feed/docs/tutorial.txt [iso-8859-1] Thu Oct 11 15:22:54 2007
@@ -100,7 +100,7 @@
 
 - add a module to the feed. Example: ::
 
-    $feed->addModule( 'ezcFeedModuleDublinCore' );
+    $feed->addModule( 'DublinCore' );
 
 - set/get a value from the feed document. Example: ::
 

Modified: trunk/Feed/src/feed.php
==============================================================================
--- trunk/Feed/src/feed.php [iso-8859-1] (original)
+++ trunk/Feed/src/feed.php [iso-8859-1] Thu Oct 11 15:22:54 2007
@@ -312,23 +312,23 @@
      *
      * Example:
      * <code>
-     * $feed->addModule( 'ezcFeedModuleDublinCode' );
+     * $feed->addModule( 'DublinCore' );
      * </code>
      *
      * @throws ezcFeedUnsupportedModuleException
      *         If the module is not supported by this feed processor.
      *
-     * @param string $className The class of the module
-     */
-    public function addModule( $className )
-    {
-        if ( !in_array( $className, self::$supportedModules ) )
-        {
-            throw new ezcFeedUnsupportedModuleException( $className );
-        }
-
+     * @param string $moduleName The name of the module
+     */
+    public function addModule( $moduleName )
+    {
+        if ( !isset( self::$supportedModules[$moduleName] ) )
+        {
+            throw new ezcFeedUnsupportedModuleException( $moduleName );
+        }
+
+        $className = self::$supportedModules[$moduleName];
         $moduleObj = new $className( $this->feedType );
-        $moduleName = $moduleObj->getModuleName();
         $this->$moduleName = $this->feedProcessor->addModule( $moduleName, 
$moduleObj );
     }
 

Modified: trunk/Feed/src/processors/rss2.php
==============================================================================
--- trunk/Feed/src/processors/rss2.php [iso-8859-1] (original)
+++ trunk/Feed/src/processors/rss2.php [iso-8859-1] Thu Oct 11 15:22:54 2007
@@ -487,7 +487,7 @@
                 $moduleNamespace = call_user_func( array( $moduleClass, 
'getNamespace' ) );
                 if ( $moduleNamespace == $node->nodeValue )
                 {
-                    $feed->addModule( $moduleClass );
+                    $feed->addModule( $moduleName );
                     $this->usedPrefixes[call_user_func( array( $moduleClass, 
'getNamespacePrefix' ) )] = $moduleName;
                 }
             }

Modified: trunk/Feed/tests/feed_test.php
==============================================================================
--- trunk/Feed/tests/feed_test.php [iso-8859-1] (original)
+++ trunk/Feed/tests/feed_test.php [iso-8859-1] Thu Oct 11 15:22:54 2007
@@ -46,7 +46,7 @@
     {
         $feed = new ezcFeed( 'rss2' );
         $this->assertEquals( false, isset( $feed->DublinCore ) );
-        $feed->addModule( 'ezcFeedModuleDublinCore' );
+        $feed->addModule( 'DublinCore' );
         $this->assertEquals( true, isset( $feed->DublinCore ) );
     }
 

Modified: trunk/Feed/tests/rss2/rss2_test.php
==============================================================================
--- trunk/Feed/tests/rss2/rss2_test.php [iso-8859-1] (original)
+++ trunk/Feed/tests/rss2/rss2_test.php [iso-8859-1] Thu Oct 11 15:22:54 2007
@@ -366,7 +366,7 @@
     public function testWithModule1()
     {
         $feed = new ezcFeed( 'rss2' );
-        $feed->addModule( 'ezcFeedModuleDublinCore' );
+        $feed->addModule( 'DublinCore' );
 
         $feed->title = "eZ Components test";
         $feed->link = "http://components.ez.no";;
@@ -384,7 +384,7 @@
     public function testComplexWithModule1()
     {
         $feed = new ezcFeed( 'rss2' );
-        $feed->addModule( 'ezcFeedModuleDublinCore' );
+        $feed->addModule( 'DublinCore' );
 
         $feed->title = "eZ Components test";
         $feed->link = "http://components.ez.no";;
@@ -451,10 +451,33 @@
         self::assertEquals( "Copyright only.", 
$feed->items[1]->DublinCore->rights );
     }
 
+    public function testParseAll()
+    {
+        $basePath = dirname( __FILE__ ) . "/data";
+        $files = scandir( $basePath );
+        foreach ( $files as $file )
+        {
+            if ( substr( $file, 0, 1 ) !== '.' && is_file( 
"{$basePath}/{$file}" ) )
+            {
+                try
+                {
+                    $feed = ezcFeed::parse( "{$basePath}/{$file}" );
+                }
+                catch ( ezcFeedUnsupportedModuleElementException $e )
+                {
+                    $this->assertEquals( "The element 'bullshit' does not 
exist for the module 'DublinCore'.", $e->getMessage() );
+                }
+                catch ( ezcFeedUnsupportedModuleItemElementException $e )
+                {
+                    $this->assertEquals( "The feed item element 'bullshit' 
does not exist for the module 'DublinCore'.", $e->getMessage() );
+                }
+            }
+        }
+    }
+
     public static function suite()
     {
          return new PHPUnit_Framework_TestSuite( "ezcFeedRss2Test" );
     }
 }
-
 ?>


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to