Author: as
Date: Mon Oct  8 18:05:48 2007
New Revision: 6395

Log:
- Fixed the documentation of exception classes.
- Ensure that all exception classes are raised at least once.

Modified:
    trunk/Feed/src/exceptions/can_not_parse.php
    trunk/Feed/src/exceptions/exception.php
    trunk/Feed/src/exceptions/item_data_missing.php
    trunk/Feed/src/exceptions/meta_data_missing.php
    trunk/Feed/src/exceptions/only_one_value_allowed.php
    trunk/Feed/src/exceptions/parse_error.php
    trunk/Feed/src/exceptions/unsupported_module.php
    trunk/Feed/src/exceptions/unsupported_module_element.php
    trunk/Feed/src/exceptions/unsupported_module_item_element.php
    trunk/Feed/src/exceptions/unsupported_type.php
    trunk/Feed/src/interfaces/processor.php
    trunk/Feed/tests/feed_test.php
    trunk/Feed/tests/rss2/rss2_test.php

Modified: trunk/Feed/src/exceptions/can_not_parse.php
==============================================================================
--- trunk/Feed/src/exceptions/can_not_parse.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/can_not_parse.php [iso-8859-1] Mon Oct  8 
18:05:48 2007
@@ -17,7 +17,13 @@
  */
 class ezcFeedCanNotParseException extends ezcFeedException
 {
-    function __construct( $uri, $extraData )
+    /**
+     * Constructs a new ezcFeedCanNotParseException.
+     *
+     * @param string $uri The URI which identifies the XML document which was 
tried to be parsed
+     * @param string $extraData An extra message to be included in the thrown 
exception text
+     */
+    public function __construct( $uri, $extraData )
     {
         parent::__construct( "The feed '{$uri}' could not be parsed: 
{$extraData}." );
     }

Modified: trunk/Feed/src/exceptions/exception.php
==============================================================================
--- trunk/Feed/src/exceptions/exception.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/exception.php [iso-8859-1] Mon Oct  8 18:05:48 
2007
@@ -10,7 +10,7 @@
  */
 
 /**
- * The general exception class as used by the Feed Classes.
+ * The general exception class used as base class for the Feed exception 
classes.
  *
  * @package Feed
  * @version //autogentag//

Modified: trunk/Feed/src/exceptions/item_data_missing.php
==============================================================================
--- trunk/Feed/src/exceptions/item_data_missing.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/item_data_missing.php [iso-8859-1] Mon Oct  8 
18:05:48 2007
@@ -17,7 +17,12 @@
  */
 class ezcFeedRequiredItemDataMissingException extends ezcFeedException
 {
-    function __construct( $attribute )
+    /**
+     * Constructs a new ezcFeedRequiredItemDataMissingException.
+     *
+     * @param string $attribute The attribute which caused the exception
+     */
+    public function __construct( $attribute )
     {
         parent::__construct( "There was no data submitted for required 
attribute '{$attribute}'." );
     }

Modified: trunk/Feed/src/exceptions/meta_data_missing.php
==============================================================================
--- trunk/Feed/src/exceptions/meta_data_missing.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/meta_data_missing.php [iso-8859-1] Mon Oct  8 
18:05:48 2007
@@ -17,7 +17,12 @@
  */
 class ezcFeedRequiredMetaDataMissingException extends ezcFeedException
 {
-    function __construct( $attribute )
+    /**
+     * Constructs a new ezcFeedRequiredMetaDataMissingException.
+     *
+     * @param string $attribute The attribute which caused the exception
+     */
+    public function __construct( $attribute )
     {
         parent::__construct( "There was no data submitted for required channel 
attribute '{$attribute}'." );
     }

Modified: trunk/Feed/src/exceptions/only_one_value_allowed.php
==============================================================================
--- trunk/Feed/src/exceptions/only_one_value_allowed.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/only_one_value_allowed.php [iso-8859-1] Mon Oct  
8 18:05:48 2007
@@ -17,7 +17,12 @@
  */
 class ezcFeedOnlyOneValueAllowedException extends ezcFeedException
 {
-    function __construct( $attribute )
+    /**
+     * Constructs a new ezcFeedOnlyOneValueAllowedException.
+     *
+     * @param string $attribute The attribute which caused the exception
+     */
+    public function __construct( $attribute )
     {
         parent::__construct( "The attribute '{$attribute}' supports only 
singular values." );
     }

Modified: trunk/Feed/src/exceptions/parse_error.php
==============================================================================
--- trunk/Feed/src/exceptions/parse_error.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/parse_error.php [iso-8859-1] Mon Oct  8 18:05:48 
2007
@@ -17,7 +17,12 @@
  */
 class ezcFeedParseErrorException extends ezcFeedException
 {
-    function __construct( $extraData )
+    /**
+     * Constructs a new ezcFeedParseErrorException.
+     *
+     * @param string $extraData An extra message to be included in the thrown 
exception text
+     */
+    public function __construct( $extraData )
     {
         parent::__construct( "Parse error while parsing feed: {$extraData}." );
     }

Modified: trunk/Feed/src/exceptions/unsupported_module.php
==============================================================================
--- trunk/Feed/src/exceptions/unsupported_module.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/unsupported_module.php [iso-8859-1] Mon Oct  8 
18:05:48 2007
@@ -10,14 +10,19 @@
  */
 
 /**
- * Thrown when an unsupported feed is created.
+ * Thrown when an unsupported module is created.
  *
  * @package Feed
  * @version //autogentag//
  */
 class ezcFeedUnsupportedModuleException extends ezcFeedException
 {
-    function __construct( $type )
+    /**
+     * Constructs a new ezcFeedUnsupportedModuleException.
+     *
+     * @param string $type The module type which caused the exception
+     */
+    public function __construct( $type )
     {
         parent::__construct( "The module '{$type}' is not supported." );
     }

Modified: trunk/Feed/src/exceptions/unsupported_module_element.php
==============================================================================
--- trunk/Feed/src/exceptions/unsupported_module_element.php [iso-8859-1] 
(original)
+++ trunk/Feed/src/exceptions/unsupported_module_element.php [iso-8859-1] Mon 
Oct  8 18:05:48 2007
@@ -17,7 +17,13 @@
  */
 class ezcFeedUnsupportedModuleElementException extends ezcFeedException
 {
-    function __construct( $module, $element )
+    /**
+     * Constructs a new ezcFeedUnsupportedModuleElementException.
+     *
+     * @param string $module The module which caused the exception
+     * @param string $element The element which caused the exception
+     */
+    public function __construct( $module, $element )
     {
         parent::__construct( "The element '{$element}' does not exist for the 
module '{$module}'." );
     }

Modified: trunk/Feed/src/exceptions/unsupported_module_item_element.php
==============================================================================
--- trunk/Feed/src/exceptions/unsupported_module_item_element.php [iso-8859-1] 
(original)
+++ trunk/Feed/src/exceptions/unsupported_module_item_element.php [iso-8859-1] 
Mon Oct  8 18:05:48 2007
@@ -17,7 +17,13 @@
  */
 class ezcFeedUnsupportedModuleItemElementException extends ezcFeedException
 {
-    function __construct( $module, $element )
+    /**
+     * Constructs a new ezcFeedUnsupportedModuleItemElementException.
+     *
+     * @param string $module The module which caused the exception
+     * @param string $element The element which caused the exception
+     */
+    public function __construct( $module, $element )
     {
         parent::__construct( "The feed item element '{$element}' does not 
exist for the module '{$module}'." );
     }

Modified: trunk/Feed/src/exceptions/unsupported_type.php
==============================================================================
--- trunk/Feed/src/exceptions/unsupported_type.php [iso-8859-1] (original)
+++ trunk/Feed/src/exceptions/unsupported_type.php [iso-8859-1] Mon Oct  8 
18:05:48 2007
@@ -17,7 +17,12 @@
  */
 class ezcFeedUnsupportedTypeException extends ezcFeedException
 {
-    function __construct( $type )
+    /**
+     * Constructs a new ezcFeedUnsupportedTypeException.
+     *
+     * @param string $type The feed type which caused the exception
+     */
+    public function __construct( $type )
     {
         parent::__construct( "The feed type '{$type}' is not supported." );
     }

Modified: trunk/Feed/src/interfaces/processor.php
==============================================================================
--- trunk/Feed/src/interfaces/processor.php [iso-8859-1] (original)
+++ trunk/Feed/src/interfaces/processor.php [iso-8859-1] Mon Oct  8 18:05:48 
2007
@@ -10,6 +10,13 @@
  */
 
 /**
+ * Base class for all feed processors.
+ *
+ * Currently implemented for these feed types:
+ *  - RSS1 ([EMAIL PROTECTED] ezcFeedRss1})
+ *  - RSS2 ([EMAIL PROTECTED] ezcFeedRss2})
+ *  - ATOM ([EMAIL PROTECTED] ezcFeedAtom})
+ *
  * @package Feed
  * @version //autogentag//
  */
@@ -48,7 +55,7 @@
     {
         if ( !$this->isModuleSupported( $moduleName ) )
         {
-            throw new ezcFeedUnsupportedModuleException( $moduleName, 'RSS' );
+            throw new ezcFeedUnsupportedModuleException( $moduleName );
         }
         $this->modules[$moduleName] = new ezcFeedModuleData( $moduleName, 
$moduleObj, $this );
         return $this->modules[$moduleName];
@@ -58,7 +65,7 @@
     {
         if ( !$this->isModuleSupported( $moduleName ) )
         {
-            throw new ezcFeedUnsupportedModuleException( $moduleName, 'RSS' );
+            throw new ezcFeedUnsupportedModuleException( $moduleName );
         }
         return new ezcFeedItemModuleData( $moduleName, $moduleObj, $item );
     }
@@ -164,6 +171,11 @@
     abstract public function setFeedItemElement( $item, $element, $value );
     abstract public function generate();
 
+    /**
+     * Returns the type of this processor (eg. 'rss1').
+     *
+     * @return string
+     */
     public function getFeedType()
     {
         return $this->feedType;

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] Mon Oct  8 18:05:48 2007
@@ -140,6 +140,38 @@
         }
     }
 
+    public function testFeedItemProperties()
+    {
+        $feed = new ezcFeed( 'rss2' );
+        $feedItem = $feed->newItem();
+
+        try
+        {
+            $value = $feedItem->no_such_property;
+            $this->fail( "Expected exception was not thrown." );
+        }
+        catch ( ezcBasePropertyNotFoundException $e )
+        {
+            $this->assertEquals( "No such property name 'no_such_property'.", 
$e->getMessage() );
+        }
+    }
+
+    public function testFeedItemSetMetaDataFail()
+    {
+        $feed = new ezcFeed( 'rss2' );
+        $feedItem = $feed->newItem();
+
+        try
+        {
+            $feedItem->setMetaData( 'title', array() );
+            $this->fail( "Expected exception was not thrown." );
+        }
+        catch ( ezcFeedOnlyOneValueAllowedException $e )
+        {
+            $this->assertEquals( "The attribute 'title' supports only singular 
values.", $e->getMessage() );
+        }
+    }
+
     public static function suite()
     {
          return new PHPUnit_Framework_TestSuite( "ezcFeedTest" );

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] Mon Oct  8 18:05:48 2007
@@ -123,6 +123,31 @@
         self::assertEquals( $expected, $feed->generate() );
     }
 
+    public function testSimpleWithItemsWithError1()
+    {
+        $feed = new ezcFeed( 'rss2' );
+        $feed->title = "eZ components test";
+        $feed->link = "http://components.ez.no";;
+        $feed->description = "This is a test for the eZ components Feed 
Generator";
+        $feed->author = "[EMAIL PROTECTED] (Derick Rethans)";
+        $feed->webMaster = "[EMAIL PROTECTED] (Derick Rethans)";
+        $feed->published = 1148633191;
+        $feed->updated = "Fri May 26, 08:46:31 2006 UTC";
+        $feed->category = "eZ components";
+
+        $item = $feed->newItem();
+
+        try
+        {
+            $feed->generate();
+            self::assertEquals( 'Expected exception not thrown' );
+        }
+        catch ( ezcFeedRequiredItemDataMissingException $e )
+        {
+            self::assertEquals( "There was no data submitted for required 
attribute 'title'.", $e->getMessage() );
+        }
+    }
+
     public function testComplex1()
     {
         $feed = new ezcFeed( 'rss2' );


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

Reply via email to