diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-16 19:42:37 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-16 19:42:37 +0200 |
commit | 8e0cbf094ea553821697091d69fff9ba59214c4b (patch) | |
tree | 61f14f1d11b732405f89e045029a8ce0d58720bb /tests/unit/fetcher | |
parent | 9e36ef31f9bf16d43326fd047619ada5ff16e072 (diff) |
fix enclosure
Diffstat (limited to 'tests/unit/fetcher')
-rw-r--r-- | tests/unit/fetcher/FeedFetcherTest.php | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/tests/unit/fetcher/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php index d5e225d76..186f94e04 100644 --- a/tests/unit/fetcher/FeedFetcherTest.php +++ b/tests/unit/fetcher/FeedFetcherTest.php @@ -34,6 +34,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { private $getProxyPort; private $proxyAuth; private $config; + private $appconfig; // items private $permalink; @@ -63,6 +64,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { 'set_proxyhost', 'set_proxyport', 'set_proxyuserpwd', + 'set_useragent', 'init', 'get_permalink', 'get_items', @@ -84,6 +86,10 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { '\OCA\News\Utility\FaviconFetcher') ->disableOriginalConstructor() ->getMock(); + $this->appconfig = $this->getMockBuilder( + '\OCA\News\Config\AppConfig') + ->disableOriginalConstructor() + ->getMock(); $this->time = 2323; $timeFactory = $this->getMock('TimeFactory', ['getTime']); $timeFactory->expects($this->any()) @@ -114,11 +120,16 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { $this->config->expects($this->any()) ->method('getFeedFetcherTimeout') ->will($this->returnValue($this->fetchTimeout)); + $this->appconfig->expects($this->any()) + ->method('getConfig') + ->with($this->equalTo('version')) + ->will($this->returnValue(3)); $this->fetcher = new FeedFetcher($this->coreFactory, $this->faviconFetcher, $timeFactory, $this->cacheDirectory, - $this->config); + $this->config, + $this->appconfig); $this->url = 'http://tests'; $this->permalink = 'http://permalink'; @@ -186,6 +197,9 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { $this->core->expects($this->once()) ->method('set_cache_duration') ->with($this->equalTo($this->cacheDuration)); + $this->core->expects($this->once()) + ->method('set_useragent') + ->with($this->equalTo('ownCloud News/3 (+https://owncloud.org/; 1 subscriber)')); $this->setExpectedException('\OCA\News\Fetcher\FetcherException'); $this->fetcher->fetch($this->url); } @@ -265,7 +279,21 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { $mock->expects($this->any()) ->method('get_type') ->will($this->returnValue($enclosureType)); - $this->expectItem('get_enclosure', $this->mock); + $mock->expects($this->any()) + ->method('get_link') + ->will($this->returnValue($this->enclosureLink)); + $this->expectItem('get_enclosure', $mock); + $item->setEnclosureMime($enclosureType); + $item->setEnclosureLink($this->enclosureLink); + } elseif ($enclosureType === 'video/ogg') { + $mock = $this->getMock('enclosure', ['get_type', 'get_link']); + $mock->expects($this->any()) + ->method('get_type') + ->will($this->returnValue($enclosureType)); + $mock->expects($this->any()) + ->method('get_link') + ->will($this->returnValue($this->enclosureLink)); + $this->expectItem('get_enclosure', $mock); $item->setEnclosureMime($enclosureType); $item->setEnclosureLink($this->enclosureLink); } @@ -308,7 +336,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { $this->core->expects($this->once()) ->method('init') ->will($this->returnValue(true)); - $item = $this->createItem(); + $item = $this->createItem(false, 'audio/ogg'); $feed = $this->createFeed(); $this->expectCore('get_items', [$this->item]); $result = $this->fetcher->fetch($this->url); @@ -396,7 +424,7 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { ->method('fetch') ->will($this->returnValue($this->webFavicon)); - $item = $this->createItem(false, true); + $item = $this->createItem(false, 'video/ogg'); $this->expectCore('get_items', [$this->item]); $result = $this->fetcher->fetch($this->url); |