diff options
-rw-r--r-- | tests/unit/utility/FeedFetcherTest.php | 15 | ||||
-rw-r--r-- | utility/feedfetcher.php | 5 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tests/unit/utility/FeedFetcherTest.php b/tests/unit/utility/FeedFetcherTest.php index 3d1f2a340..ba2e5c191 100644 --- a/tests/unit/utility/FeedFetcherTest.php +++ b/tests/unit/utility/FeedFetcherTest.php @@ -50,6 +50,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { private $pub; private $body; private $author; + private $authorMail; private $enclosureLink; // feed @@ -108,6 +109,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { $this->feedLink = 'http://goatse'; $this->feedImage = '/an/image'; $this->webFavicon = 'http://anon.google.com'; + $this->authorMail = 'doe@joes.com'; } @@ -160,7 +162,7 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { ->will($this->returnValue($return)); } - + private function createItem($author=false, $enclosureType=null) { $this->expectItem('get_permalink', $this->permalink); $this->expectItem('get_title', $this->title); @@ -185,6 +187,17 @@ class FeedFetcherTest extends \OCA\AppFramework\Utility\TestUtility { ->will($this->returnValue($this->author)); $this->expectItem('get_author', $mock); $item->setAuthor(html_entity_decode($this->author)); + } else { + $mock = $this->getMock('author', array('get_name', 'get_email')); + $mock->expects($this->any()) + ->method('get_name') + ->will($this->returnValue('')); + $mock->expects($this->any()) + ->method('get_email') + ->will($this->returnValue($this->authorMail)); + + $this->expectItem('get_author', $mock); + $item->setAuthor(html_entity_decode($this->authorMail)); } if($enclosureType === 'audio/ogg') { diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php index ab1b92a4d..e97373836 100644 --- a/utility/feedfetcher.php +++ b/utility/feedfetcher.php @@ -120,8 +120,9 @@ class FeedFetcher implements IFeedFetcher { $author = $simplePieItem->get_author(); if ($author !== null) { - if ($author->get_name()) { - $item->setAuthor(html_entity_decode($author->get_name())); + $name = html_entity_decode($author->get_name()); + if ($name) { + $item->setAuthor($name); } else { $item->setAuthor(html_entity_decode($author->get_email())); } |