summaryrefslogtreecommitdiffstats
path: root/tests/Unit/Db/ItemMapperAfterTest.php
diff options
context:
space:
mode:
authorMarco Nassabain <marco.nassabain@hotmail.com>2021-02-28 22:46:56 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-04-08 22:31:21 +0200
commit702d611f354af61095bdf33792b3404f6edaefd3 (patch)
tree89171c693768c6a7b6911213297f11b4d0f96f5b /tests/Unit/Db/ItemMapperAfterTest.php
parent85dbed9ffaa7245d2672346e49b9dca9a57864b8 (diff)
🔀 Resolving merge: moving shared tests
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests/Unit/Db/ItemMapperAfterTest.php')
-rw-r--r--tests/Unit/Db/ItemMapperAfterTest.php115
1 files changed, 115 insertions, 0 deletions
diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php
index 68bad19dc..75804e629 100644
--- a/tests/Unit/Db/ItemMapperAfterTest.php
+++ b/tests/Unit/Db/ItemMapperAfterTest.php
@@ -319,6 +319,121 @@ class ItemMapperAfterTest extends MapperTestUtility
$this->assertEquals([Item::fromRow(['id' => 4])], $result);
}
+ public function testFindAllSharedAfter()
+ {
+ $this->db->expects($this->once())
+ ->method('getQueryBuilder')
+ ->willReturn($this->builder);
+
+ $this->builder->expects($this->once())
+ ->method('select')
+ ->with('items.*')
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->once())
+ ->method('from')
+ ->with('news_items', 'items')
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->exactly(2))
+ ->method('andWhere')
+ ->withConsecutive(
+ ['items.last_modified >= :updatedSince'],
+ ['items.shared_with = :sharedWith']
+ )
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->exactly(1))
+ ->method('setParameters')
+ ->with([
+ 'updatedSince' => 1610903351,
+ 'sharedWith' => 'jack',
+ ])
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->once())
+ ->method('orderBy')
+ ->with('items.last_modified', 'DESC')
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->once())
+ ->method('addOrderBy')
+ ->with('items.id', 'DESC')
+ ->willReturnSelf();
+
+ $this->builder->expects($this->once())
+ ->method('execute')
+ ->will($this->returnValue($this->cursor));
+
+ $this->cursor->expects($this->exactly(2))
+ ->method('fetch')
+ ->willReturnOnConsecutiveCalls(
+ ['id' => 4],
+ false
+ );
+
+ $result = $this->class->findAllSharedAfter('jack', 1610903351, false);
+ $this->assertEquals([Item::fromRow(['id' => 4])], $result);
+ }
+
+ public function testFindAllSharedAfterHideRead()
+ {
+ $this->db->expects($this->once())
+ ->method('getQueryBuilder')
+ ->willReturn($this->builder);
+
+ $this->builder->expects($this->once())
+ ->method('select')
+ ->with('items.*')
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->once())
+ ->method('from')
+ ->with('news_items', 'items')
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->exactly(3))
+ ->method('andWhere')
+ ->withConsecutive(
+ ['items.last_modified >= :updatedSince'],
+ ['items.shared_with = :sharedWith'],
+ ['items.unread = 1']
+ )
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->exactly(1))
+ ->method('setParameters')
+ ->with([
+ 'updatedSince' => 1610903351,
+ 'sharedWith' => 'jack'
+ ])
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->once())
+ ->method('orderBy')
+ ->with('items.last_modified', 'DESC')
+ ->will($this->returnSelf());
+
+ $this->builder->expects($this->once())
+ ->method('addOrderBy')
+ ->with('items.id', 'DESC')
+ ->willReturnSelf();
+
+ $this->builder->expects($this->once())
+ ->method('execute')
+ ->will($this->returnValue($this->cursor));
+
+ $this->cursor->expects($this->exactly(2))
+ ->method('fetch')
+ ->willReturnOnConsecutiveCalls(
+ ['id' => 4],
+ false
+ );
+
+ $result = $this->class->findAllSharedAfter('jack', 1610903351, true);
+ $this->assertEquals([Item::fromRow(['id' => 4])], $result);
+ }
+
public function testFindAllAfterUnread()
{
$this->db->expects($this->once())