diff options
Diffstat (limited to 'tests/Unit/Db/FolderMapperTest.php')
-rw-r--r-- | tests/Unit/Db/FolderMapperTest.php | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/Unit/Db/FolderMapperTest.php b/tests/Unit/Db/FolderMapperTest.php index dd87b22b5..026c16bc6 100644 --- a/tests/Unit/Db/FolderMapperTest.php +++ b/tests/Unit/Db/FolderMapperTest.php @@ -279,4 +279,94 @@ class FolderMapperTest extends MapperTestUtility $result = $this->class->findAll(); $this->assertEquals($this->folders, $result); } + + /** + * @covers \OCA\News\Db\FolderMapperV2::read + */ + public function testRead() + { + $this->db->expects($this->once()) + ->method('getQueryBuilder') + ->willReturn($this->builder); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items', 'items') + ->will($this->returnSelf()); + + $this->builder->expects($this->once()) + ->method('innerJoin') + ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') + ->will($this->returnSelf()); + + $this->builder->expects($this->once()) + ->method('setValue') + ->with('unread', 0) + ->will($this->returnSelf()); + + $this->builder->expects($this->exactly(2)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId']) + ->will($this->returnSelf()); + + $this->builder->expects($this->exactly(2)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['folderId', 1]) + ->will($this->returnSelf()); + + $this->builder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('QUERY')); + + $this->db->expects($this->exactly(1)) + ->method('executeUpdate') + ->with('QUERY'); + + $this->class->read('admin', 1); + } + + /** + * @covers \OCA\News\Db\FolderMapperV2::read + */ + public function testReadWithMaxId() + { + $this->db->expects($this->once()) + ->method('getQueryBuilder') + ->willReturn($this->builder); + + $this->builder->expects($this->once()) + ->method('update') + ->with('news_items', 'items') + ->will($this->returnSelf()); + + $this->builder->expects($this->once()) + ->method('innerJoin') + ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') + ->will($this->returnSelf()); + + $this->builder->expects($this->once()) + ->method('setValue') + ->with('unread', 0) + ->will($this->returnSelf()); + + $this->builder->expects($this->exactly(3)) + ->method('andWhere') + ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId'], ['items.id =< :maxItemId']) + ->will($this->returnSelf()); + + $this->builder->expects($this->exactly(3)) + ->method('setParameter') + ->withConsecutive(['userId', 'admin'], ['folderId', 1], ['maxItemId', 4]) + ->will($this->returnSelf()); + + $this->builder->expects($this->exactly(1)) + ->method('getSQL') + ->will($this->returnValue('QUERY')); + + $this->db->expects($this->exactly(1)) + ->method('executeUpdate') + ->with('QUERY'); + + $this->class->read('admin', 1, 4); + } }
\ No newline at end of file |