Author: Derick Rethans Date: 2006-12-14 13:30:28 +0100 (Thu, 14 Dec 2006) New Revision: 4281
Log: - Added the ezcFeed::parseContent() method that parses a feed contained in a variable. Modified: trunk/Feed/ChangeLog trunk/Feed/src/feed.php trunk/Feed/tests/rss2_test.php Modified: trunk/Feed/ChangeLog =================================================================== --- trunk/Feed/ChangeLog 2006-12-14 12:26:39 UTC (rev 4280) +++ trunk/Feed/ChangeLog 2006-12-14 12:30:28 UTC (rev 4281) @@ -1,3 +1,10 @@ +1.0beta1 - [RELEASEDATE] +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Added the ezcFeed::parseContent() method that parses a feed contained in a + variable. + + 1.0alpha1 - Tuesday 24 October 2006 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: trunk/Feed/src/feed.php =================================================================== --- trunk/Feed/src/feed.php 2006-12-14 12:26:39 UTC (rev 4280) +++ trunk/Feed/src/feed.php 2006-12-14 12:30:28 UTC (rev 4281) @@ -57,7 +57,22 @@ { throw new ezcBaseFileNotFoundException( $uri ); } - + return self::dispatchXml( $xml ); + } + + static public function parseContent( $content ) + { + $xml = new DomDocument; + $retval = @$xml->loadXML( $content ); + if ( $retval === false ) + { + throw new ezcFeedParseErrorException( "Content is no valid XML." ); + } + return self::dispatchXml( $xml ); + } + + protected static function dispatchXml( DOMDocument $xml ) + { foreach ( self::$supportedFeedTypes as $feedType => $feedClass ) { $canParse = call_user_func( array( $feedClass, 'canParse' ), $xml ); @@ -68,7 +83,7 @@ } } - throw new ezcFeedCanNotParseException( $uri, 'Feed type not recognized' ); + throw new ezcFeedCanNotParseException( $xml->documentURI, 'Feed type not recognised' ); } static public function getSupportedTypes() Modified: trunk/Feed/tests/rss2_test.php =================================================================== --- trunk/Feed/tests/rss2_test.php 2006-12-14 12:26:39 UTC (rev 4280) +++ trunk/Feed/tests/rss2_test.php 2006-12-14 12:30:28 UTC (rev 4281) @@ -304,6 +304,15 @@ self::assertEquals( "Copyright only.", $feed->items[1]->DublinCore->rights ); } + public function testParseComplexWithModuleFromVariable() + { + $feed = ezcFeed::parseContent( file_get_contents( dirname( __FILE__ ) . "/data/rss2-09.xml" ) ); + self::assertEquals( "<p>This is a richer <i>description</i> supported by dublin code.</p>", $feed->DublinCore->description ); + self::assertEquals( "CreativeCommons", $feed->items[0]->DublinCore->rights ); + self::assertEquals( "This is the second item", $feed->items[1]->description ); + self::assertEquals( "Copyright only.", $feed->items[1]->DublinCore->rights ); + } + public static function suite() { return new PHPUnit_Framework_TestSuite( "ezcFeedRss2Test" ); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components