From d7c7c5342df537916e21c5158cfb1d5e2b7d977b Mon Sep 17 00:00:00 2001 From: bastei Date: Wed, 4 Sep 2013 07:06:06 +0200 Subject: allow multiple xpath results --- utility/articleenhancer/articleenhancer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utility/articleenhancer/articleenhancer.php b/utility/articleenhancer/articleenhancer.php index 7565070f8..5b670341a 100644 --- a/utility/articleenhancer/articleenhancer.php +++ b/utility/articleenhancer/articleenhancer.php @@ -88,11 +88,11 @@ abstract class ArticleEnhancer { * @return the result as a string */ protected function domToString($xpathResult) { - if($xpathResult->length > 0) { - return $this->toInnerHTML($xpathResult->item(0)); - } else { - return ""; + $result = ""; + foreach($xpathResult as $node) { + $result = $result . $this->toInnerHTML($node); } + return $result; } -- cgit v1.2.3 From 2f22e43a91b8dfae6ca8e8b8fa1cf41f08ff7ceb Mon Sep 17 00:00:00 2001 From: bastei Date: Wed, 4 Sep 2013 07:09:42 +0200 Subject: fix limit calculation for deleteReadOlderThanThreshold --- db/itemmapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/itemmapper.php b/db/itemmapper.php index 1dd9726e4..e66b8c166 100644 --- a/db/itemmapper.php +++ b/db/itemmapper.php @@ -259,7 +259,7 @@ class ItemMapper extends Mapper implements IMapper { while($row = $result->fetchRow()) { - $limit = $threshold - $row['size']; + $limit = $row['size'] - $threshold; if($limit > 0) { $params = array($status, $row['feed_id']); -- cgit v1.2.3 From 3c98e6423b8f7c6f42728cc32422c197db7e6767 Mon Sep 17 00:00:00 2001 From: bastei Date: Thu, 5 Sep 2013 00:43:22 +0200 Subject: little fix: shorter concatenation --- utility/articleenhancer/articleenhancer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/articleenhancer/articleenhancer.php b/utility/articleenhancer/articleenhancer.php index 5b670341a..76bb0fa9f 100644 --- a/utility/articleenhancer/articleenhancer.php +++ b/utility/articleenhancer/articleenhancer.php @@ -90,7 +90,7 @@ abstract class ArticleEnhancer { protected function domToString($xpathResult) { $result = ""; foreach($xpathResult as $node) { - $result = $result . $this->toInnerHTML($node); + $result .= $this->toInnerHTML($node); } return $result; } -- cgit v1.2.3 From 99ba6461928e7d8bbe421eca3c0bf3446bb9df62 Mon Sep 17 00:00:00 2001 From: bastei Date: Thu, 5 Sep 2013 02:34:45 +0200 Subject: deleteReadOlderThanThreshold unit test fix --- tests/unit/db/ItemMapperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php index de6edeba6..fe1de517a 100644 --- a/tests/unit/db/ItemMapperTest.php +++ b/tests/unit/db/ItemMapperTest.php @@ -320,7 +320,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { 'HAVING COUNT(*) > ?'; $threshold = 10; - $rows = array(array('feed_id' => 30, 'size' => 11)); + $rows = array(array('feed_id' => 30, 'size' => 9)); $params = array($status, $threshold); $this->setMapperResult($sql, $params, $rows); @@ -340,7 +340,7 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility { $params1 = array($status, $threshold); - $row = array('feed_id' => 30, 'size' => 9); + $row = array('feed_id' => 30, 'size' => 11); $sql2 = 'DELETE FROM `*PREFIX*news_items` `items` ' . 'WHERE NOT ((`status` & ?) > 0) ' . -- cgit v1.2.3 From 772999e5628e62286c95f7e11635585404660a88 Mon Sep 17 00:00:00 2001 From: bastei Date: Thu, 5 Sep 2013 02:51:20 +0200 Subject: ArticleEnhancer unit test modified for multiple XPath-results --- tests/unit/utility/articleenhancer/ArticleEnhancerTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php b/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php index 5f82a4752..a59bf9485 100644 --- a/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php +++ b/tests/unit/utility/articleenhancer/ArticleEnhancerTest.php @@ -58,7 +58,7 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->fileFactory, array( '/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/img', - '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div[2]/div' + '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div' ), $this->timeout ); @@ -106,7 +106,7 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $file->body = '
-
nooo
+
nooo
hiho
rawr
@@ -122,11 +122,11 @@ class ArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { ->will($this->returnValue($file)); $this->purifier->expects($this->once()) ->method('purify') - ->with($this->equalTo('
rawr
')) - ->will($this->returnValue('
rawr
')); + ->with($this->equalTo('
hiho
rawr
')) + ->will($this->returnValue('
hiho
rawr
')); $result = $this->testEnhancer->enhance($item); - $this->assertEquals('
rawr
', $result->getBody()); + $this->assertEquals('
hiho
rawr
', $result->getBody()); } -- cgit v1.2.3