diff options
author | Marco Nassabain <marco.nassabain@hotmail.com> | 2021-02-27 21:26:45 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 22:31:21 +0200 |
commit | 5c359a8d42020d58c57f55980bb547b38216c379 (patch) | |
tree | 3bd34cc1c26f2315db75164096cc800316bea543 /tests/Unit | |
parent | 14c668534478dc5e22e5b199eb4a2e364959fdf6 (diff) |
✅ ItemServiceTest: test share functions
- testFindAllShared
- testFindAllNewShared
- testSharedCount
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/Service/ItemServiceTest.php | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php index 410f87904..ff12a53f0 100644 --- a/tests/Unit/Service/ItemServiceTest.php +++ b/tests/Unit/Service/ItemServiceTest.php @@ -113,6 +113,17 @@ class ItemServiceTest extends TestCase $result = $this->class->findAllInFolderAfter($this->user, 2, 20333, true); $this->assertEquals([], $result); } + + public function testFindAllNewShared() + { + $this->mapper->expects($this->once()) + ->method('findAllSharedAfter') + ->with('jack', 20333, true) + ->will($this->returnValue([])); + + $result = $this->class->findAllSharedAfter($this->user, 20333, true); + $this->assertEquals([], $result); + } public function testFindAllNewItem() { @@ -177,23 +188,20 @@ class ItemServiceTest extends TestCase public function testFindAllShared() { - $type = FeedType::SHARED; - $this->mapper->expects($this->once()) - ->method('findAllShared') - ->with( - $this->equalTo(20), - $this->equalTo(5), - $this->equalTo(true), - $this->equalTo(true), - $this->equalTo('jack'), - $this->equalTo([]) - ) + $this->mapper->expects($this->once()) + ->method('findAllSharedWithUser') + ->with('user', 20, 5, true, true, []) ->will($this->returnValue(['val'])); - $result = $this->itemService->findAllItems( - 3, $type, 20, 5, - true, true, 'jack' + $result = $this->class->findAllSharedWithUserWithFilters( + 'user', + 20, + 5, + true, + true, + [] ); + $this->assertEquals(['val'], $result); } @@ -709,4 +717,16 @@ class ItemServiceTest extends TestCase $this->class->share('sender', 1, 'recipient'); } + + public function testSharedCount() + { + $this->mapper->expects($this->once()) + ->method('findAllFromUser') + ->with('user', ['shared_with' => 'user', 'unread' => true]) + ->will($this->returnValue([new Item(), new Item()])); + + $result = $this->class->sharedWithUser('user'); + + $this->assertEquals(2, count($result)); + } } |