From 5c359a8d42020d58c57f55980bb547b38216c379 Mon Sep 17 00:00:00 2001 From: Marco Nassabain Date: Sat, 27 Feb 2021 21:26:45 +0100 Subject: =?UTF-8?q?=E2=9C=85=20ItemServiceTest:=20test=20share=20functions?= =?UTF-8?q?=20-=20testFindAllShared=20-=20testFindAllNewShared=20-=20testS?= =?UTF-8?q?haredCount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Nassabain --- tests/Unit/Service/ItemServiceTest.php | 48 ++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'tests') 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)); + } } -- cgit v1.2.3