From 8d082488e9e62914d79c179d376d1a0529183c49 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 28 Jan 2019 06:03:16 +0100 Subject: [PATCH] Improve checks & add tests --- src/Wallabag/ImportBundle/Import/PocketImport.php | 6 +++--- tests/Wallabag/ImportBundle/Import/PocketImportTest.php | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index a9b43993..5737928d 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -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']) { diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index baa5d905..8083f1a8 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php @@ -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 -- 2.41.0