From 78d3e2164116f299effb11d25b1971e6d375366e Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 22 Oct 2014 01:35:59 +0200 Subject: get rid of simplepie --- .../articleenhancer/XPathArticleEnhancerTest.php | 189 ++++++--------------- tests/unit/config/ConfigTest.php | 26 +-- tests/unit/controller/AdminControllerTest.php | 18 +- tests/unit/fetcher/FeedFetcherTest.php | 165 +++++------------- tests/unit/utility/SimplePieAPIFactoryTest.php | 34 ---- 5 files changed, 106 insertions(+), 326 deletions(-) delete mode 100644 tests/unit/utility/SimplePieAPIFactoryTest.php (limited to 'tests') diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php index 00c4e7cb0..33f0e75ab 100644 --- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php @@ -19,78 +19,49 @@ use \OCA\News\Db\Item; class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { private $testEnhancer; - private $fileFactory; - private $timeout; - private $redirects; - private $headers; - private $userAgent; - private $proxyHost; - private $proxyPort; - private $proxyAuth; + private $client; + private $clientFactory; protected function setUp() { $this->timeout = 30; - $this->fileFactory = $this - ->getMockBuilder('\OCA\News\Utility\SimplePieAPIFactory') + $this->clientFactory = $this + ->getMockBuilder('\OCA\News\Utility\PicoFeedClientFactory') ->disableOriginalConstructor() ->getMock(); - $this->proxyHost = 'test'; - $this->proxyPort = 3; - $this->proxyAuth = 'hi'; - $this->config = $this->getMockBuilder( - '\OCA\News\Config\Config') + $this->client = $this + ->getMockBuilder('\PicoFeed\Client') ->disableOriginalConstructor() ->getMock(); - $this->config->expects($this->any()) - ->method('getProxyHost') - ->will($this->returnValue('')); - $this->config->expects($this->any()) - ->method('getProxyAuth') - ->will($this->returnValue($this->proxyAuth)); - $this->config->expects($this->any()) - ->method('getProxyPort') - ->will($this->returnValue($this->proxyPort)); - $this->config->expects($this->any()) - ->method('getFeedFetcherTimeout') - ->will($this->returnValue($this->timeout)); $this->testEnhancer = new XPathArticleEnhancer( - $this->fileFactory, + $this->clientFactory, [ '/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/span', '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div', '/explosm.net\/all/' => '//body/*', '/themerepublic.net/' => '//*[@class=\'post hentry\']' - ], - $this->config + ] ); - $this->redirects = 5; - $this->headers = null; $this->userAgent = 'Mozilla/5.0 AppleWebKit'; } - - public function testXPathUsesNoProxy() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ''; - $item = new Item(); - $item->setUrl('https://www.explosm.net/comics/312'); - $item->setBody('Hello thar'); - - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent), - $this->equalTo(false)) - ->will($this->returnValue($file)); - - $result = $this->testEnhancer->enhance($item); - $this->assertEquals('Hello thar', $result->getBody()); + private function setUpFile($body, $encoding, $url) { + $this->clientFactory->expects($this->once()) + ->method('build') + ->will($this->returnValue($this->client)); + $this->client->expects($this->once()) + ->method('execute') + ->with($this->equalTo($url)); + $this->client->expects($this->once()) + ->method('setUserAgent') + ->with($this->equalTo($this->userAgent)); + $this->client->expects($this->once()) + ->method('getContent') + ->will($this->returnValue($body)); + $this->client->expects($this->once()) + ->method('getEncoding') + ->will($this->returnValue($encoding)); } @@ -102,9 +73,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testDoesModifiyArticlesThatMatch() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ' + $encoding = 'utf-8'; + $body = '
nooo
@@ -116,14 +86,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://www.explosm.net/comics/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals('
hiho
', $result->getBody()); @@ -131,9 +94,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testDoesModifiyAllArticlesThatMatch() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ' + $encoding = 'utf-8'; + $body = '
nooo
hiho
@@ -145,14 +107,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://www.explosm.net/shorts/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals('
hiho
rawr
', @@ -161,9 +116,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testModificationHandlesEmptyResults() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ' + $encoding = 'utf-8'; + $body = '
@@ -173,14 +127,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://www.explosm.net/comics/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals('Hello thar', $result->getBody()); @@ -188,21 +135,13 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testModificationDoesNotBreakOnEmptyDom() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ''; + $encoding = 'utf-8'; + $body = ''; $item = new Item(); $item->setUrl('https://www.explosm.net/comics/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals('Hello thar', $result->getBody()); @@ -210,9 +149,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testModificationDoesNotBreakOnBrokenDom() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = '

+ $encoding = 'utf-8'; + $body = '

@@ -222,14 +160,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://www.explosm.net/comics/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals('Hello thar', $result->getBody()); @@ -237,9 +168,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { public function testTransformRelativeUrls() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ' + $encoding = 'utf-8'; + $body = ' link link2 @@ -250,14 +180,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://www.explosm.net/all/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals('
' . @@ -272,9 +195,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { } public function testTransformRelativeUrlSpecials() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ' + $encoding = 'utf-8'; + $body = ' @@ -283,14 +205,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://username:secret@www.explosm.net/all/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals( @@ -301,9 +216,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { } public function testDontTransformAbsoluteUrlsAndMails() { - $file = new \stdClass; - $file->headers = ["content-type"=>"text/html; charset=utf-8"]; - $file->body = ' + $encoding = 'utf-8'; + $body = ' mail @@ -313,14 +227,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $item->setUrl('https://www.explosm.net/all/312'); $item->setBody('Hello thar'); - $this->fileFactory->expects($this->once()) - ->method('getFile') - ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout), - $this->equalTo($this->redirects), - $this->equalTo($this->headers), - $this->equalTo($this->userAgent)) - ->will($this->returnValue($file)); + $this->setUpFile($body, $encoding, $item->getUrl()); $result = $this->testEnhancer->enhance($item); $this->assertEquals( diff --git a/tests/unit/config/ConfigTest.php b/tests/unit/config/ConfigTest.php index 9aaac57c5..a2739de59 100644 --- a/tests/unit/config/ConfigTest.php +++ b/tests/unit/config/ConfigTest.php @@ -42,7 +42,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { public function testDefaults() { $this->assertEquals(60, $this->config->getAutoPurgeMinimumInterval()); $this->assertEquals(200, $this->config->getAutoPurgeCount()); - $this->assertEquals(30*60, $this->config->getCacheDuration()); + $this->assertEquals(10, $this->config->getMaxRedirects()); $this->assertEquals(60, $this->config->getFeedFetcherTimeout()); $this->assertEquals(true, $this->config->getUseCronUpdates()); $this->assertEquals(8080, $this->config->getProxyPort()); @@ -128,13 +128,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { public function testWrite () { $json = 'autoPurgeMinimumInterval = 60' . "\n" . 'autoPurgeCount = 3' . "\n" . - 'cacheDuration = 1800' . "\n" . + 'maxRedirects = 10' . "\n" . 'feedFetcherTimeout = 60' . "\n" . - 'useCronUpdates = true' . "\n" . - 'proxyHost = yo man' . "\n" . - 'proxyPort = 12' . "\n" . - 'proxyUser = this is a test' . "\n". - 'proxyPassword = se'; + 'useCronUpdates = true'; $this->config->setAutoPurgeCount(3); $this->config->setProxyHost('yo man'); $this->config->setProxyPort(12); @@ -165,13 +161,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $json = 'autoPurgeMinimumInterval = 60' . "\n" . 'autoPurgeCount = 200' . "\n" . - 'cacheDuration = 1800' . "\n" . + 'maxRedirects = 10' . "\n" . 'feedFetcherTimeout = 60' . "\n" . - 'useCronUpdates = false' . "\n" . - 'proxyHost = ' . "\n" . - 'proxyPort = 8080' . "\n" . - 'proxyUser = ' . "\n" . - 'proxyPassword = '; + 'useCronUpdates = false'; $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -205,11 +197,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->assertSame(61, $interval); } - public function testCacheDuration() { - $this->config->setCacheDuration(21); - $duration = $this->config->getCacheDuration(); + public function testMaxRedirects() { + $this->config->setMaxRedirects(21); + $redirects = $this->config->getMaxRedirects(); - $this->assertSame(21, $duration); + $this->assertSame(21, $redirects); } public function testFeedFetcherTimeout() { diff --git a/tests/unit/controller/AdminControllerTest.php b/tests/unit/controller/AdminControllerTest.php index b468823da..4a9bf7764 100644 --- a/tests/unit/controller/AdminControllerTest.php +++ b/tests/unit/controller/AdminControllerTest.php @@ -45,7 +45,7 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $expected = [ 'autoPurgeMinimumInterval' => 1, 'autoPurgeCount' => 2, - 'cacheDuration' => 3, + 'maxRedirects' => 3, 'feedFetcherTimeout' => 4, 'useCronUpdates' => 5 ]; @@ -56,8 +56,8 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { ->method('getAutoPurgeCount') ->will($this->returnValue($expected['autoPurgeCount'])); $this->config->expects($this->once()) - ->method('getCacheDuration') - ->will($this->returnValue($expected['cacheDuration'])); + ->method('getMaxRedirects') + ->will($this->returnValue($expected['maxRedirects'])); $this->config->expects($this->once()) ->method('getFeedFetcherTimeout') ->will($this->returnValue($expected['feedFetcherTimeout'])); @@ -80,7 +80,7 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $expected = [ 'autoPurgeMinimumInterval' => 1, 'autoPurgeCount' => 2, - 'cacheDuration' => 3, + 'maxRedirects' => 3, 'feedFetcherTimeout' => 4, 'useCronUpdates' => 5 ]; @@ -92,8 +92,8 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { ->method('setAutoPurgeCount') ->with($this->equalTo($expected['autoPurgeCount'])); $this->config->expects($this->once()) - ->method('setCacheDuration') - ->with($this->equalTo($expected['cacheDuration'])); + ->method('setMaxRedirects') + ->with($this->equalTo($expected['maxRedirects'])); $this->config->expects($this->once()) ->method('setFeedFetcherTimeout') ->with($this->equalTo($expected['feedFetcherTimeout'])); @@ -111,8 +111,8 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { ->method('getAutoPurgeCount') ->will($this->returnValue($expected['autoPurgeCount'])); $this->config->expects($this->once()) - ->method('getCacheDuration') - ->will($this->returnValue($expected['cacheDuration'])); + ->method('getMaxRedirects') + ->will($this->returnValue($expected['maxRedirects'])); $this->config->expects($this->once()) ->method('getFeedFetcherTimeout') ->will($this->returnValue($expected['feedFetcherTimeout'])); @@ -123,7 +123,7 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $response = $this->controller->update( $expected['autoPurgeMinimumInterval'], $expected['autoPurgeCount'], - $expected['cacheDuration'], + $expected['maxRedirects'], $expected['feedFetcherTimeout'], $expected['useCronUpdates'] ); diff --git a/tests/unit/fetcher/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php index ff1581082..d87d88952 100644 --- a/tests/unit/fetcher/FeedFetcherTest.php +++ b/tests/unit/fetcher/FeedFetcherTest.php @@ -20,21 +20,14 @@ use \OCA\News\Db\Feed; class FeedFetcherTest extends \PHPUnit_Framework_TestCase { private $fetcher; - private $core; - private $coreFactory; + private $parser; + private $reader; + private $client; private $faviconFetcher; + private $parsedFeed; private $url; - private $cacheDirectory; - private $cacheDuration; private $time; private $item; - private $purifier; - private $fetchTimeout; - private $proxyHost; - private $getProxyPort; - private $proxyAuth; - private $config; - private $appconfig; // items private $permalink; @@ -53,41 +46,25 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { private $webFavicon; protected function setUp(){ - $this->core = $this->getMock( - '\SimplePie_Core', [ - 'set_timeout', - 'set_feed_url', - 'enable_cache', - 'set_stupidly_fast', - 'set_cache_location', - 'set_cache_duration', - 'set_proxyhost', - 'set_proxyport', - 'set_proxyuserpwd', - 'set_useragent', - 'init', - 'get_permalink', - 'get_items', - 'get_title', - 'get_image_url' - ]); - $this->coreFactory = $this->getMockBuilder( - '\OCA\News\Utility\SimplePieAPIFactory') + $this->reader = $this->getMockBuilder( + '\PicoFeed\Reader') ->disableOriginalConstructor() ->getMock(); - $this->coreFactory->expects($this->any()) - ->method('getCore') - ->will($this->returnValue($this->core)); - $this->item = $this->getMockBuilder( - '\SimplePie_Item') + $this->parser = $this->getMockBuilder( + '\PicoFeed\Parser') ->disableOriginalConstructor() ->getMock(); - $this->faviconFetcher = $this->getMockBuilder( - '\PicoFeed\Favicon') + $this->client = $this->getMockBuilder( + '\PicoFeed\Client') + ->disableOriginalConstructor() + ->getMock(); + $this->parsedFeed = $this->getMockBuilder( + '\PicoFeed\Feed') ->disableOriginalConstructor() ->getMock(); - $this->appconfig = $this->getMockBuilder( - '\OCA\News\Config\AppConfig') + + $this->faviconFetcher = $this->getMockBuilder( + '\PicoFeed\Favicon') ->disableOriginalConstructor() ->getMock(); $this->time = 2323; @@ -95,41 +72,9 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { $timeFactory->expects($this->any()) ->method('getTime') ->will($this->returnValue($this->time)); - $this->cacheDuration = 100; - $this->cacheDirectory = 'dir/'; - $this->proxyHost = 'test'; - $this->proxyPort = 30; - $this->proxyAuth = 'hi'; - $this->fetchTimeout = 40; - $this->config = $this->getMockBuilder( - '\OCA\News\Config\Config') - ->disableOriginalConstructor() - ->getMock(); - $this->config->expects($this->any()) - ->method('getCacheDuration') - ->will($this->returnValue($this->cacheDuration)); - $this->config->expects($this->any()) - ->method('getProxyHost') - ->will($this->returnValue($this->proxyHost)); - $this->config->expects($this->any()) - ->method('getProxyAuth') - ->will($this->returnValue($this->proxyAuth)); - $this->config->expects($this->any()) - ->method('getProxyPort') - ->will($this->returnValue($this->proxyPort)); - $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->fetcher = new FeedFetcher($this->reader, $this->faviconFetcher, - $timeFactory, - $this->cacheDirectory, - $this->config, - $this->appconfig); + $timeFactory); $this->url = 'http://tests'; $this->permalink = 'http://permalink'; @@ -156,65 +101,35 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($this->fetcher->canHandle($url)); } - - public function testDoesNotUseProxyIfNotEnabled() { - $this->config->expects($this->any()) - ->method('getProxyHost') - ->will($this->returnValue('')); - $this->core->expects($this->never()) - ->method('set_proxyhost'); - $this->core->expects($this->never()) - ->method('set_proxyport'); - $this->core->expects($this->never()) - ->method('set_proxyuserpwd'); + private function setUpReader($url='', $modified=true) { + $this->reader->expects($this->once()) + ->method('download') + ->with($this->equalTo($url)) + ->will($this->returnValue($this->client)); + $this->client->expects($this->once()) + ->method('getLastModified') + ->with() + ->will($this->returnValue($modified)); } - public function testFetchThrowsExceptionWhenInitFailed() { - $this->core->expects($this->once()) - ->method('set_feed_url') - ->with($this->equalTo($this->url)); - $this->core->expects($this->once()) - ->method('enable_cache') - ->with($this->equalTo(true)); - $this->core->expects($this->once()) - ->method('set_timeout') - ->with($this->equalTo($this->fetchTimeout)); - $this->core->expects($this->once()) - ->method('set_cache_location') - ->with($this->equalTo($this->cacheDirectory)); - $this->core->expects($this->once()) - ->method('set_proxyhost') - ->with($this->equalTo($this->proxyHost)); - $this->core->expects($this->once()) - ->method('set_proxyport') - ->with($this->equalTo($this->proxyPort)); - $this->core->expects($this->once()) - ->method('set_proxyuserpwd') - ->with($this->equalTo($this->proxyAuth)); - $this->core->expects($this->once()) - ->method('set_stupidly_fast') - ->with($this->equalTo(true)); - $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; ' . - 'feed-url=http://tests)')); + public function testFetchThrowsExceptionWhenFetchingFailed() { + $this->setUpReader($this->url); + $this->reader->expects($this->once()) + ->method('getParser') + ->will($this->returnValue(false)); + $this->setExpectedException('\OCA\News\Fetcher\FetcherException'); $this->fetcher->fetch($this->url); } - public function testShouldCatchExceptionsAndThrowOwnException() { - $this->core->expects($this->once()) - ->method('init') - ->will($this->returnValue(true)); - $this->core->expects($this->once()) - ->method('get_items') - ->will($this->throwException(new \Exception('oh noes!'))); + public function testFetchThrowsExceptionWhenParsingFailed() { + $this->setUpReader($this->url); + $this->reader->expects($this->once()) + ->method('getParser') + ->will($this->returnValue(false)); + $this->setExpectedException('\OCA\News\Fetcher\FetcherException'); $this->fetcher->fetch($this->url); } diff --git a/tests/unit/utility/SimplePieAPIFactoryTest.php b/tests/unit/utility/SimplePieAPIFactoryTest.php deleted file mode 100644 index 4f401a72e..000000000 --- a/tests/unit/utility/SimplePieAPIFactoryTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @author Bernhard Posselt - * @copyright Alessandro Cosentino 2012 - * @copyright Bernhard Posselt 2012, 2014 - */ - -namespace OCA\News\Utility; - - -class SimplePieAPIFactoryTest extends \PHPUnit_Framework_TestCase { - - - public function testGetFile() { - $factory = new SimplePieAPIFactory(); - $file = $factory->getFile('php://input', 10, 5, $headers='headers', - $useragent='flashce', $force_fsockopen=true); - $this->assertTrue($file instanceof \SimplePie_File); - } - - - public function testGetCore() { - $factory = new SimplePieAPIFactory(); - $this->assertTrue($factory->getCore() instanceof \SimplePie); - } - - -} \ No newline at end of file -- cgit v1.2.3