Skip to content

Commit

Permalink
Fix notices in case of empty feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Aug 4, 2014
1 parent f95e0a7 commit 84ae676
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/Creator/AtomCreator10.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ function createFeed() {
$feed.= $this->_createGeneratorComment();
$feed.= $this->_createStylesheetReferences();
$feed.= "<feed xmlns=\"http://www.w3.org/2005/Atom\"";
if ($this->items[0]->lat!="") {
if (!empty($this->items[0]->lat))
{
$feed.= " xmlns:georss=\"http://www.georss.org/georss\"\n";
}
if ($this->language!="") {
if ($this->language!=""){
$feed.= " xml:lang=\"".$this->language."\"";
}
$feed.= ">\n";
Expand Down
8 changes: 6 additions & 2 deletions lib/Creator/RSSCreator10.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ function createFeed() {
$feed.= " xmlns=\"http://purl.org/rss/1.0/\"\n";
$feed.= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
$feed.= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n";
if ($this->items[0]->thumb!="")
if (!empty($this->items[0]->thumb))
{
$feed.= " xmlns:photo=\"http://www.pheed.com/pheed/\"\n";
if ($this->items[0]->lat!="")
}
if (!empty($this->items[0]->lat))
{
$feed.= " xmlns:georss=\"http://www.georss.org/georss\"\n";
}
$feed.= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n";
$feed.= " <channel rdf:about=\"".$this->syndicationURL."\">\n";
$feed.= " <title>".htmlspecialchars($this->title)."</title>\n";
Expand Down
13 changes: 13 additions & 0 deletions test/Creator/AtomCreator10Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
class AtomCreator10Test extends PHPUnit_Framework_TestCase
{
public function test_create_empty_feed()
{
$creator = new UniversalFeedCreator;
$creator->description = 'Feed Description';
$feed = $creator->createFeed('ATOM1.0');

$parsed = simplexml_load_string($feed);
$this->assertEquals('Feed Description', $parsed->subtitle);
}
}
13 changes: 13 additions & 0 deletions test/Creator/RSSCreator10Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
class RSSCreator10Test extends PHPUnit_Framework_TestCase
{
public function test_create_empty_feed()
{
$creator = new UniversalFeedCreator;
$creator->description = 'Feed Description';
$feed = $creator->createFeed('RSS1.0');

$parsed = simplexml_load_string($feed);
$this->assertEquals('Feed Description', $parsed->channel->description);
}
}

0 comments on commit 84ae676

Please sign in to comment.