From 98c3aece10f7e687592b8b683c7b98736304d2fb Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Thu, 31 Mar 2022 18:48:18 +0200 Subject: Partly fix test Signed-off-by: Benjamin Brahmer --- lib/Db/FeedMapperV2.php | 8 ++++---- lib/Db/FolderMapperV2.php | 7 ++++--- tests/Unit/Db/FeedMapperTest.php | 12 ++++++------ tests/Unit/Db/FolderMapperTest.php | 12 ++++++------ 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/Db/FeedMapperV2.php b/lib/Db/FeedMapperV2.php index 3a6494e06..c80bf118b 100644 --- a/lib/Db/FeedMapperV2.php +++ b/lib/Db/FeedMapperV2.php @@ -186,16 +186,16 @@ class FeedMapperV2 extends NewsMapperV2 }, $this->db->executeQuery($idBuilder->getSQL(), $idBuilder->getParameters())->fetchAll() ); - - $builder = $this->db->getQueryBuilder(); $time = new Time(); + $builder = $this->db->getQueryBuilder(); $builder->update(ItemMapperV2::TABLE_NAME) ->set('unread', $builder->createParameter('unread')) - ->set('last_modified', $time->getMicroTime()) + ->set('last_modified', $builder->createParameter('last_modified')) ->andWhere('id IN (:idList)') ->andWhere('unread != :unread') ->setParameter('unread', false, IQueryBuilder::PARAM_BOOL) - ->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY); + ->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY) + ->setParameter('last_modified', $time->getMicroTime(), IQueryBuilder::PARAM_STR); return $this->db->executeStatement( $builder->getSQL(), diff --git a/lib/Db/FolderMapperV2.php b/lib/Db/FolderMapperV2.php index 0944c7ab6..9afda11c4 100644 --- a/lib/Db/FolderMapperV2.php +++ b/lib/Db/FolderMapperV2.php @@ -128,15 +128,16 @@ class FolderMapperV2 extends NewsMapperV2 return intval($value['id']); }, $this->db->executeQuery($idBuilder->getSQL(), $idBuilder->getParameters())->fetchAll()); - $builder = $this->db->getQueryBuilder(); $time = new Time(); + $builder = $this->db->getQueryBuilder(); $builder->update(ItemMapperV2::TABLE_NAME) ->set('unread', $builder->createParameter('unread')) - ->set('last_modified', $time->getMicroTime()) + ->set('last_modified', $builder->createParameter('last_modified')) ->andWhere('id IN (:idList)') ->andWhere('unread != :unread') ->setParameter('unread', false, IQueryBuilder::PARAM_BOOL) - ->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY); + ->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY) + ->setParameter('last_modified', $time->getMicroTime(), IQueryBuilder::PARAM_STR); return $this->db->executeStatement( $builder->getSQL(), diff --git a/tests/Unit/Db/FeedMapperTest.php b/tests/Unit/Db/FeedMapperTest.php index 499989062..51c2adcec 100644 --- a/tests/Unit/Db/FeedMapperTest.php +++ b/tests/Unit/Db/FeedMapperTest.php @@ -519,13 +519,13 @@ class FeedMapperTest extends MapperTestUtility ->with('news_items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('createParameter') ->will($this->returnArgument(0)); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('set') - ->with('unread', 'unread') + ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) @@ -616,7 +616,7 @@ class FeedMapperTest extends MapperTestUtility ->with('SQL QUERY') ->willReturn($result); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('createParameter') ->will($this->returnArgument(0)); @@ -625,9 +625,9 @@ class FeedMapperTest extends MapperTestUtility ->with('news_items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('set') - ->with('unread', 'unread') + ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) diff --git a/tests/Unit/Db/FolderMapperTest.php b/tests/Unit/Db/FolderMapperTest.php index a7f9f0c9d..1d621b501 100644 --- a/tests/Unit/Db/FolderMapperTest.php +++ b/tests/Unit/Db/FolderMapperTest.php @@ -342,7 +342,7 @@ class FolderMapperTest extends MapperTestUtility ->with('SQL QUERY') ->willReturn($result); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('createParameter') ->will($this->returnArgument(0)); @@ -351,9 +351,9 @@ class FolderMapperTest extends MapperTestUtility ->with('news_items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('set') - ->with('unread', 'unread') + ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) @@ -445,7 +445,7 @@ class FolderMapperTest extends MapperTestUtility ->with('SQL QUERY') ->willReturn($result); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('createParameter') ->will($this->returnArgument(0)); @@ -454,9 +454,9 @@ class FolderMapperTest extends MapperTestUtility ->with('news_items') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->exactly(2)) ->method('set') - ->with('unread', 'unread') + ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(2)) -- cgit v1.2.3