]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Improve checks & add tests 3819/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 28 Jan 2019 05:03:16 +0000 (06:03 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 28 Jan 2019 05:03:16 +0000 (06:03 +0100)
src/Wallabag/ImportBundle/Import/PocketImport.php
tests/Wallabag/ImportBundle/Import/PocketImportTest.php

index a9b43993f735057b7656fe301e0baf2cda7fd018..5737928d169afd66a3456bb94c8e1d8b6b84b0e8 100644 (file)
@@ -206,10 +206,10 @@ class PocketImport extends AbstractImport
         $this->fetchContent($entry, $url);
 
         // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
-        $entry->setArchived(1 == $importedEntry['status'] || $this->markAsRead);
+        $entry->setArchived(1 === (int) $importedEntry['status'] || $this->markAsRead);
 
-        // 0 or 1 - 1 If the item is starred
-        $entry->setStarred(1 == $importedEntry['favorite']);
+        // 0 or 1 - 1 if the item is starred
+        $entry->setStarred(1 === (int) $importedEntry['favorite']);
 
         $title = 'Untitled';
         if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) {
index baa5d90571dd09ecd603f66c0f9a4e2e3bbdcb4f..8083f1a8801a8791aaae4c1488afee9f3e9dfcb3 100644 (file)
@@ -226,6 +226,13 @@ class PocketImportTest extends TestCase
             ->method('getRepository')
             ->willReturn($entryRepo);
 
+        $this->em
+            ->expects($this->any())
+            ->method('persist')
+            ->with($this->callback(function ($persistedEntry) {
+                return $persistedEntry->isArchived() && $persistedEntry->isStarred();
+            }));
+
         $entry = new Entry($this->user);
 
         $this->contentProxy