summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-22 18:38:29 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-22 18:38:29 +0200
commit830398682f93ea76a35d542ac65f944fe5aa9f38 (patch)
treea7110ea259aaaa8f135b1dc1818a441c8967a49c /tests
parentd72ddb277f2d03ddd9700dd640350dcebc6b1cc8 (diff)
dont add items with no title or guid or url and handle non existent pubdate
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/utility/ImportParserTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/utility/ImportParserTest.php b/tests/unit/utility/ImportParserTest.php
index 5c4a6292c..4014988a4 100644
--- a/tests/unit/utility/ImportParserTest.php
+++ b/tests/unit/utility/ImportParserTest.php
@@ -111,4 +111,40 @@ class ImportParserTest extends \OCA\AppFramework\Utility\TestUtility {
$this->assertEquals(array($out), $result);
}
+
+ public function testDontAddIfNoTitleAndUrlAndGuid() {
+ $in = array(
+ 'items' => array(
+ array(
+ "published" => 1365415485,
+
+ "summary" => array(
+ "content" => "1596 seeder(s), 775 leecher(s), 8005 download(s) - 316.7 MiB - Trusted"
+ )
+ )
+ )
+ );
+
+ $result = $this->parser->parse($in);
+ $this->assertEquals(array(), $result);
+ }
+
+ public function testParsesItemsNoPubDate() {
+ unset($this->in['items'][0]['published']);
+ $result = $this->parser->parse($this->in);
+
+ $out = new Item();
+ $out->setTitle($this->in['items'][0]['title']);
+ $out->setPubDate($this->time);
+ $out->setBody($this->in['items'][0]['summary']['content']);
+ $out->setUrl($this->in['items'][0]['alternate'][0]['href']);
+ $out->setGuid($this->in['items'][0]['id']);
+ $out->setGuidHash(md5($this->in['items'][0]['id']));
+ $out->setStatus(0);
+ $out->setUnread();
+ $out->setStarred();
+
+ $this->assertEquals(array($out), $result);
+ }
+
}