summaryrefslogtreecommitdiffstats
path: root/tests/Unit/Service
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-02-27 21:06:01 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit14c668534478dc5e22e5b199eb4a2e364959fdf6 (patch)
treeffb5fc1513d813b77a4c7674b14c421d49f0988a /tests/Unit/Service
parent75e81d5e0b3e982a388c0587357102420df4c495 (diff)
✅ ItemServiceTest: test share function
- testShare - testShareDoesNotExist Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests/Unit/Service')
-rw-r--r--tests/Unit/Service/ItemServiceTest.php54
1 files changed, 42 insertions, 12 deletions
diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php
index 04c89ae28..410f87904 100644
--- a/tests/Unit/Service/ItemServiceTest.php
+++ b/tests/Unit/Service/ItemServiceTest.php
@@ -654,29 +654,59 @@ class ItemServiceTest extends TestCase
$this->class->purgeOverThreshold(5);
}
- public function testShareItem()
+ public function testShare()
{
$itemId = 3;
+ $item = new Item();
+ $item->setGuid('_guid_')
+ ->setGuidHash(md5('_guid_'))
+ ->setUrl('_url_')
+ ->setTitle('_title_')
+ ->setAuthor('_author_')
+ ->setPubDate(1)
+ ->setBody('_body_')
+ ->setEnclosureMime('_enclosureMime_')
+ ->setEnclosureLink('_enclosureLink_')
+ ->setMediaThumbnail('_mediaThumbnail_')
+ ->setMediaDescription('_mediaDescription_')
+ ->setRtl('_rtl_')
+ ->setFingerprint('_fingerprint_')
+ ->setContentHash('_contentHash_')
+ ->setSearchIndex('_searchIndex_')
+ ->setUnread(0)
+ ->setStarred(1)
+ ->setFeedId(10);
+
+ $sharedItem = Item::fromImport($item->jsonSerialize());
+ $sharedItem->setUnread(true)
+ ->setStarred(false)
+ ->setFeedId($item->getFeedId())
+ ->setFingerprint($item->getFingerprint())
+ ->setContentHash($item->getContentHash())
+ ->setSearchIndex($item->getSearchIndex())
+ ->setSharedBy('sender')
+ ->setSharedWith('recipient');
+
$this->mapper->expects($this->once())
- ->method('shareItem')
- ->with(
- $this->equalTo($itemId),
- $this->equalTo('john'),
- $this->equalTo('jack')
- )
- ->will($this->returnValue(new Item()));
+ ->method('findFromUser')
+ ->with('sender', $itemId)
+ ->will($this->returnValue($item));
- $this->itemService->shareItem($itemId, 'john','jack');
+ $this->mapper->expects($this->once())
+ ->method('insert')
+ ->with($sharedItem);
+
+ $this->class->share('sender', $itemId, 'recipient');
}
- public function testShareItemDoesNotExist()
+ public function testShareDoesNotExist()
{
$this->expectException(ServiceNotFoundException::class);
$this->mapper->expects($this->once())
- ->method('shareItem')
+ ->method('findFromUser')
->will($this->throwException(new DoesNotExistException('')));
- $this->itemService->shareItem(1, 'john', 'jack');
+ $this->class->share('sender', 1, 'recipient');
}
}