コード例 #1
0
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../../..'));
define('SF_APP', 'frontend');
include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php';
$b = new sfTestBrowser();
$b->initialize();
$feedParams = array('title' => 'foo', 'link' => 'http://foobar', 'description' => 'foobar baz', 'language' => 'fr', 'authorName' => 'francois', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://bar.baz', 'subtitle' => 'hey, foo, this is bar', 'categories' => array('foo', 'bar'), 'feedUrl' => 'http://www.example.com', 'encoding' => 'UTF-16');
$enclosureParams = array('url' => 'foo.com', 'length' => '1234', 'mimeType' => 'foobarmimetype');
$enclosure = new sfFeedEnclosure();
$enclosure->initialize($enclosureParams);
$itemParams = array('title' => 'fooitem', 'link' => 'http://www.example.com/item1', 'description' => 'foobar baz item', 'content' => 'this is foo bar baz', 'authorName' => 'francois item', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://bar.baz.item', 'categories' => array('fooitem', 'baritem'), 'pubDate' => '12345', 'comments' => 'gee', 'uniqueId' => '98765', 'enclosure' => $enclosure, 'categories' => array('fooitem', 'baritem'));
$item2Params = array('title' => 'foobaritem', 'pubDate' => '123456', 'link' => 'http://www.example.com');
$image_params = array('title' => 'symfony project', 'link' => 'http://www.symfony-project.org', 'favicon' => 'http://www.symfony-project.org/favicon.ico', 'image' => 'http://www.symfony-project.org/images/symfony_logo.gif', 'faviconX' => '16', 'faviconY' => '16', 'imageX' => '176', 'imageY' => '37');
$feed = new sfAtom1Feed();
$feed->initialize($feedParams);
$feedItem = new sfFeedItem();
$feedItem->initialize($itemParams);
$feed->addItem($feedItem);
$feedItem2 = new sfFeedItem();
$feedItem2->initialize($item2Params);
$feed->addItem($feedItem2);
$feedImage = new sfFeedImage();
$feedImage->initialize($image_params);
$feed->setImage($feedImage);
$t = new lime_test(57, new lime_output_color());
$t->diag('toXML() - generated feed');
$feedString = $feed->toXml();
$feedXml = simplexml_load_string($feedString);
$namespaces = $feedXml->getNamespaces();
$t->ok(in_array('http://www.w3.org/2005/Atom', $namespaces), '<feed> is declared with the proper Atom namespace');