fix readAll

Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
This commit is contained in:
Benjamin Brahmer 2022-08-31 15:25:50 +02:00
parent a41abf808f
commit a7f69c4b63
2 changed files with 8 additions and 7 deletions

View File

@ -276,10 +276,10 @@ class ItemMapperV2 extends NewsMapperV2
->innerJoin('items', FeedMapperV2::TABLE_NAME, 'feeds', 'items.feed_id = feeds.id')
->andWhere('feeds.user_id = :userId')
->andWhere('items.id <= :maxItemId')
->andWhere('items.unread != :unread')
->andWhere('items.unread = :unread')
->setParameter('userId', $userId)
->setParameter('maxItemId', $maxItemId)
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL);
->setParameter('unread', true, IQueryBuilder::PARAM_BOOL);
$idList = array_map(function ($value): int {
return intval($value['id']);
@ -289,7 +289,8 @@ class ItemMapperV2 extends NewsMapperV2
$builder->update(self::TABLE_NAME)
->set('unread', $builder->createParameter('unread'))
->andWhere('id IN (:idList)')
->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY);
->setParameter('idList', $idList, IQueryBuilder::PARAM_INT_ARRAY)
->setParameter('unread', false, IQueryBuilder::PARAM_BOOL);
return $this->db->executeStatement(
$builder->getSQL(),

View File

@ -499,12 +499,12 @@ class ItemMapperTest extends MapperTestUtility
$selectbuilder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(['feeds.user_id = :userId'], ['items.id <= :maxItemId'], ['items.unread != :unread'])
->withConsecutive(['feeds.user_id = :userId'], ['items.id <= :maxItemId'], ['items.unread = :unread'])
->will($this->returnSelf());
$selectbuilder->expects($this->exactly(3))
->method('setParameter')
->withConsecutive(['userId', 'admin'], ['maxItemId', 4], ['unread', false])
->withConsecutive(['userId', 'admin'], ['maxItemId', 4], ['unread', true])
->will($this->returnSelf());
$selectbuilder->expects($this->exactly(1))
@ -547,9 +547,9 @@ class ItemMapperTest extends MapperTestUtility
->withConsecutive(['id IN (:idList)'])
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))
$this->builder->expects($this->exactly(2))
->method('setParameter')
->withConsecutive(['idList', [1, 2]])
->withConsecutive(['idList', [1, 2]], ['unread', false])
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))