include dirname(__FILE__) . '/../../../../test/bootstrap/unit.php'; require_once dirname(__FILE__) . '/../../lib/sfFeed.class.php'; require_once dirname(__FILE__) . '/../../lib/sfFeedItem.class.php'; $t = new lime_test(20, new lime_output_color()); $feed_params = array('title' => 'foo', 'link' => 'bar', 'description' => 'foobar baz', 'language' => 'fr', 'authorName' => 'francois', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://francois.toto.com', 'subtitle' => 'this is foo bar', 'categories' => array('foo', 'bar'), 'feedUrl' => 'http://www.example.com', 'encoding' => 'UTF-16'); $feed = new sfFeed(); $t->isa_ok($feed->initialize($feed_params), 'sfFeed', 'initialize() returns the current feed object'); $t->is($feed->getTitle(), $feed_params['title'], 'getTitle() gets the feed title'); $t->is($feed->getLink(), $feed_params['link'], 'getLink() gets the feed link'); $t->is($feed->getDescription(), $feed_params['description'], 'getDescription() gets the feed description'); $t->is($feed->getLanguage(), $feed_params['language'], 'getLanguage() gets the feed language'); $t->is($feed->getAuthorName(), $feed_params['authorName'], 'getAuthorName() gets the feed author name'); $t->is($feed->getAuthorEmail(), $feed_params['authorEmail'], 'getAuthorEmail() gets the feed author email'); $t->is($feed->getAuthorLink(), $feed_params['authorLink'], 'getAuthorLink() gets the feed author link'); $t->is($feed->getSubtitle(), $feed_params['subtitle'], 'getSubtitle() gets the feed subtitle'); $t->is($feed->getCategories(), $feed_params['categories'], 'getCategories() gets the feed categories'); $t->is($feed->getFeedUrl(), $feed_params['feedUrl'], 'getFeedUrl() gets the feed url'); $t->is($feed->getEncoding(), $feed_params['encoding'], 'getEncoding() gets the feed encoding'); try { $feed->addItem('foobar'); $t->fail('addItem() refuses non-sfFeedItem objects'); } catch (Exception $e) { $t->pass('addItem() refuses non-sfFeedItem objects'); } try { $feed->addItem(new sfFeedItem()); $t->pass('addItem() accepts sfFeedItem objects'); } catch (Exception $e) { $t->fail('addItem() accepts sfFeedItem objects'); } $t->is(count($feed->getItems()), 1, 'addItem() adds an item to the feed');