diff options
-rw-r--r-- | articleenhancer/xpatharticleenhancer.php | 8 | ||||
-rw-r--r-- | tests/unit/articleenhancer/XPathArticleEnhancerTest.php | 46 |
2 files changed, 45 insertions, 9 deletions
diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 99aa61177..586f65151 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -57,7 +57,13 @@ class XPathArticleEnhancer implements ArticleEnhancer { foreach($this->regexXPathPair as $regex => $search) { if(preg_match($regex, $item->getUrl())) { - $file = $this->fileFactory->getFile($item->getUrl(), $this->maximumTimeout, "Mozilla/5.0 AppleWebKit"); + $file = $this->fileFactory->getFile( + $item->getUrl(), + $this->maximumTimeout, + 5, + null, + "Mozilla/5.0 AppleWebKit" + ); // convert encoding by detecting charset from header $contentType = $file->headers['content-type']; diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php index 65e16fb4b..c7e61e7b8 100644 --- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php @@ -35,6 +35,9 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { private $testEnhancer; private $fileFactory; private $timeout; + private $redirects; + private $headers; + private $userAgent; protected function setUp() { $timeout = 30; @@ -52,6 +55,9 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { ), $this->timeout ); + $this->redirects = 5; + $this->headers = null; + $this->userAgent = 'Mozilla/5.0 AppleWebKit'; } @@ -80,7 +86,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -106,7 +115,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -130,7 +142,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -149,7 +164,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -173,7 +191,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -198,7 +219,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -220,7 +244,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); @@ -243,7 +270,10 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory->expects($this->once()) ->method('getFile') ->with($this->equalTo($item->getUrl()), - $this->equalTo($this->timeout)) + $this->equalTo($this->timeout), + $this->equalTo($this->redirects), + $this->equalTo($this->headers), + $this->equalTo($this->userAgent)) ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); |