From 2c07af4842fa69d95070e2a9676c5d4306cf3d86 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 8 Oct 2014 13:41:53 +0200 Subject: remove dead proxy code from favicon fetcher --- appinfo/application.php | 3 +- tests/unit/utility/FaviconFetcherTest.php | 65 +------------------------------ utility/faviconfetcher.php | 13 +------ 3 files changed, 4 insertions(+), 77 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index 297b00ad9..6028d7c1c 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -446,8 +446,7 @@ class Application extends App { $container->registerService('FaviconFetcher', function($c) { return new FaviconFetcher( - $c->query('SimplePieAPIFactory'), - $c->query('Config') + $c->query('SimplePieAPIFactory') ); }); diff --git a/tests/unit/utility/FaviconFetcherTest.php b/tests/unit/utility/FaviconFetcherTest.php index b7499fd36..a9c1416dc 100644 --- a/tests/unit/utility/FaviconFetcherTest.php +++ b/tests/unit/utility/FaviconFetcherTest.php @@ -20,15 +20,9 @@ class FaviconFetcherTest extends \PHPUnit_Framework_TestCase { private $fetcher; private $fileFactory; private $png; - private $proxyHost; - private $proxyPort; - private $proxyAuth; protected function setUp(){ $this->png = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A"; - $this->proxyHost = 'test'; - $this->proxyPort = 3; - $this->proxyAuth = 'hi'; $this->fileFactory = $this->getMockBuilder( '\OCA\News\Utility\SimplePieAPIFactory') ->disableOriginalConstructor() @@ -37,16 +31,7 @@ class FaviconFetcherTest extends \PHPUnit_Framework_TestCase { '\OCA\News\Utility\Config') ->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->fetcher = new FaviconFetcher($this->fileFactory, $this->config); + $this->fetcher = new FaviconFetcher($this->fileFactory); } @@ -84,54 +69,6 @@ class FaviconFetcherTest extends \PHPUnit_Framework_TestCase { } - public function testProxySettingsAreUsed() { - $this->config = $this->getMockBuilder( - '\OCA\News\Utility\Config') - ->disableOriginalConstructor() - ->getMock(); - $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->fetcher = new FaviconFetcher($this->fileFactory, $this->config); - - $faviconPath = "/owncloud/core/img/favicon.png"; - $html = $this->getFaviconHTML($faviconPath); - - $url = 'http://google.com'; - $pageMock = $this->getFileMock($html); - $pngMock = $this->getFileMock($this->png); - - $this->fileFactory->expects($this->at(0)) - ->method('getFile') - ->with($this->equalTo('http://google.com')) - ->will($this->returnValue($pageMock)); - - $this->fileFactory->expects($this->at(1)) - ->method('getFile') - ->with($this->equalTo( - 'http://google.com/owncloud/core/img/favicon.png'), - $this->equalTo(10), - $this->equalTo(5), - $this->equalTo(null), - $this->equalTo(null), - $this->equalTo(false), - $this->equalTo($this->proxyHost), - $this->equalTo($this->proxyPort), - $this->equalTo($this->proxyAuth)) - ->will($this->returnValue($pngMock)); - - $favicon = $this->fetcher->fetch($url); - - $this->assertEquals('http://google.com/owncloud/core/img/favicon.png', $favicon); - } - - public function testNoProxySettingsAreUsed() { $faviconPath = "/owncloud/core/img/favicon.png"; $html = $this->getFaviconHTML($faviconPath); diff --git a/utility/faviconfetcher.php b/utility/faviconfetcher.php index cadc90210..7ffdad9d7 100644 --- a/utility/faviconfetcher.php +++ b/utility/faviconfetcher.php @@ -19,16 +19,14 @@ use \ZendXml\Security; class FaviconFetcher { private $apiFactory; - private $config; /** * Inject a factory to build a simplepie file object. This is needed because * the file object contains logic in its constructor which makes it * impossible to inject and test */ - public function __construct(SimplePieAPIFactory $apiFactory, Config $config) { + public function __construct(SimplePieAPIFactory $apiFactory) { $this->apiFactory = $apiFactory; - $this->config = $config; } @@ -102,15 +100,8 @@ class FaviconFetcher { private function getFile($url) { - if(trim($this->config->getProxyHost()) === '') { - return $this->apiFactory->getFile($url, 10, 5, null, null, false, + return $this->apiFactory->getFile($url, 10, 5, null, null, false, null, null, null); - } else { - return $this->apiFactory->getFile($url, 10, 5, null, null, false, - $this->config->getProxyHost(), - $this->config->getProxyPort(), - $this->config->getProxyAuth()); - } } -- cgit v1.2.3