Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Merge cbadd67 into ab45a8a
Browse files Browse the repository at this point in the history
  • Loading branch information
mazsudo committed Jan 23, 2019
2 parents ab45a8a + cbadd67 commit b77db78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Entity/MessageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected function prepareStateQuery($state, $types, $batchSize, &$parameters)
$query = $this->getRepository()
->createQueryBuilder('m')
->where('m.state = :state')
->orderBy('m.createdAt');
->orderBy('m.createdAt', 'DESC');

$parameters['state'] = $state;

Expand Down
16 changes: 16 additions & 0 deletions tests/Entity/MessageManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ public function testGetPagerWithInProgressMessages(): void
->getPager(['state' => MessageInterface::STATE_IN_PROGRESS], 1);
}

public function testFindByTypes(): void
{
$self = $this;
$this
->getMessageManager(function ($qb) use ($self): void {
$qb->expects($self->never())->method('andWhere');
$qb->expects($self->once())->method('where')->willReturnSelf();
$qb->expects($self->once())->method('setParameters')->with(['state' => MessageInterface::STATE_OPEN]);
$qb->expects($self->once())->method('orderBy')->with(
$self->equalTo('m.createdAt'),
$self->equalTo('DESC')
)->willReturnSelf();
})
->findByTypes([], MessageInterface::STATE_OPEN, 10);
}

/**
* @return MessageManagerMock
*/
Expand Down

0 comments on commit b77db78

Please sign in to comment.