public function testRunRegression($file)
 {
     $errors = array();
     $outFile = $this->outFileName($file, '.in', '.out');
     try {
         $parsed = ezcFeed::parseContent(file_get_contents($file));
         $expected = (include_once $outFile);
         $this->cleanForCompare($expected, $parsed);
     } catch (ezcFeedException $e) {
         $parsed = $e->getMessage();
         $expected = trim(file_get_contents($outFile));
     }
     $this->assertEquals(var_export($expected, true), var_export($parsed, true), "The " . basename($outFile) . " is not the same as the parsed feed from " . basename($file) . ".");
 }
Ejemplo n.º 2
0
    /**
     * Test for issue #15625: RSS 0.90 feeds are parsed as RSS 1.0 feeds
     * It tests if when parsing an RSS 0.90 feed the parser throws an ezcFeedParseErrorException
     */
    public function testParseRss090()
    {
        try {
            $xml = <<<EOT
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://channel.netscape.com/rdf/simple/0.9/">

  <channel>
    <title>Mozilla Dot Org</title>
    <link>http://www.mozilla.org</link>
    <description>the Mozilla Organization
      web site</description>
  </channel>

  <image>
    <title>Mozilla</title>
    <url>http://www.mozilla.org/images/moz.gif</url>
    <link>http://www.mozilla.org</link>
  </image>

  <item>
    <title>New Status Updates</title>
    <link>http://www.mozilla.org/status/</link>
  </item>
</rdf:RDF>
EOT;
            $feed = ezcFeed::parseContent($xml);
            $this->fail("Expected exception was not thrown.");
        } catch (ezcFeedParseErrorException $e) {
        }
    }
Ejemplo n.º 3
0
 /**
  * Executes the PHP function for the operator cleanup and modifies $operatorValue.
  * 
  * @param eZTemplate $tpl
  * @param string $operatorName
  * @param array $operatorParameters
  * @param string $rootNamespace
  * @param string $currentNamespace
  * @param mixed $operatorValue
  * @param array $namedParameters
  */
 public function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case 'feedreader':
             $source = isset($namedParameters['source']) ? $namedParameters['source'] : '';
             $limit = isset($namedParameters['limit']) ? $namedParameters['limit'] : 0;
             $offset = isset($namedParameters['offset']) ? $namedParameters['offset'] : 0;
             $res = array();
             $sourceXML = eZHTTPTool::getDataByURL($namedParameters['source']);
             try {
                 $feed = ezcFeed::parseContent($sourceXML);
             } catch (Exception $e) {
                 $res['error'] = $e->getMessage();
                 $operatorValue = $res;
                 return;
             }
             $res['title'] = isset($feed->title) ? $feed->title->__toString() : null;
             $res['links'] = self::buildLinksArray(isset($feed->link) ? $feed->link : array());
             $items = isset($feed->item) ? $feed->item : array();
             $counter = 0;
             foreach ($items as $item) {
                 $counter++;
                 if ($counter <= $offset) {
                     continue;
                 }
                 $title = isset($item->title) ? $item->title->__toString() : null;
                 $description = isset($item->description) ? $item->description->__toString() : null;
                 $content = isset($item->content) ? $item->content->__toString() : null;
                 $published = isset($item->published) ? $item->published->date->format('U') : null;
                 $links = self::buildLinksArray(isset($item->link) ? $item->link : array());
                 $res['items'][] = array('title' => $title, 'links' => $links, 'description' => $description, 'content' => $content, 'published' => $published);
                 if ($counter == $limit + $offset) {
                     break;
                 }
             }
             $operatorValue = $res;
             break;
     }
 }
Ejemplo n.º 4
0
 public function testParseRss2Version094()
 {
     $feed = ezcFeed::parseContent('<?xml version="1.0" encoding="utf-8"?><rss version="0.94"><channel><title>RSS 0.94</title><item><title>Item 0.94</title></item></channel></rss>');
     $this->assertEquals('rss2', $feed->getFeedType());
     $this->assertEquals('RSS 0.94', $feed->title->__toString());
     $this->assertEquals('Item 0.94', $feed->item[0]->title->__toString());
 }