コード例 #1
0
$t->is((string) $feedXml->entry[0]->title, $itemParams['title'], '<entry><title> contains the item title');
$t->is((string) $feedXml->entry[0]->link['href'], $itemParams['link'], '<entry><link ref="alternate"> contains the proper item link');
$t->is((string) $feedXml->entry[0]->updated, gmstrftime('%Y-%m-%dT%H:%M:%SZ', $itemParams['pubDate']), '<entry><updated> contains the proper item publication date');
$t->is((string) $feedXml->entry[0]->author->name, $itemParams['authorName'], '<entry><author><name> contains the item author name');
$t->is((string) $feedXml->entry[0]->author->email, $itemParams['authorEmail'], '<entry><author><author_email> contains the item author email');
$t->is((string) $feedXml->entry[0]->author->uri, $itemParams['authorLink'], '<entry><author><author_link> contains the item author link');
$t->is((string) $feedXml->entry[0]->id, $itemParams['uniqueId'], '<entry><id> contains the item description');
$t->is((string) $feedXml->entry[0]->summary, $itemParams['description'], '<entry><summary> contains the item description');
$t->is((string) $feedXml->entry[0]->content, $itemParams['content'], '<entry><content> contains the item content');
$t->is((string) $feedXml->entry[0]->category[0]['term'], $itemParams['categories'][0], '<entry><category> contains the item category');
$t->is((string) $feedXml->entry[0]->category[1]['term'], $itemParams['categories'][1], '<entry><category> contains the item category');
$t->is((string) $feedXml->entry[0]->link[1]['href'], $enclosureParams['url'], '<entry><link ref="enclosure"> contains the proper item enclosure url');
$t->is((string) $feedXml->entry[0]->link[1]['length'], $enclosureParams['length'], '<entry><link ref="enclosure"> contains the proper item enclosure length');
$t->is((string) $feedXml->entry[0]->link[1]['type'], $enclosureParams['mimeType'], '<entry><link ref="enclosure"> contains the proper item enclosure mimeType');
$t->diag('asXML() - generated feed');
$feedString = $feed->asXml();
$t->is(sfContext::getInstance()->getResponse()->getContentType(), 'application/atom+xml; charset=UTF-16', 'The response comes with the correct Content-Type');
$t->diag('fromXML() - generated feed');
$generatedFeed = new sfAtom1Feed();
$generatedFeed->fromXml($feedString);
$t->is($generatedFeed->getTitle(), $feed->getTitle(), 'The title property is properly set');
$t->is($generatedFeed->getLink(), $feed->getLink(), 'The link property is properly set');
$t->isnt($generatedFeed->getDescription(), $feed->getDescription(), 'The description property cannot be set from an Atom feed');
$t->is($generatedFeed->getLanguage(), $feed->getLanguage(), 'The language property is properly set');
$t->is($generatedFeed->getAuthorEmail(), $feed->getAuthorEmail(), 'The author email property is properly set');
$t->is($generatedFeed->getAuthorName(), $feed->getAuthorName(), 'The author name property is properly set');
$t->is($generatedFeed->getAuthorLink(), $feed->getAuthorLink(), 'The author link property is properly set');
$t->is($generatedFeed->getSubtitle(), $feed->getSubtitle(), 'The subtitle property is properly set');
$t->is($generatedFeed->getCategories(), $feed->getCategories(), 'The categories property is properly set');
$t->is($generatedFeed->getFeedUrl(), $feed->getFeedUrl(), 'The feedUrl property is properly set');
$t->is($generatedFeed->getEncoding(), $feed->getEncoding(), 'The encoding property is properly set');