diff --git a/Tests/Unit/EventListener/EventListenerInvokerTest.php b/Tests/Unit/EventListener/EventListenerInvokerTest.php index c213ec9..d701db7 100644 --- a/Tests/Unit/EventListener/EventListenerInvokerTest.php +++ b/Tests/Unit/EventListener/EventListenerInvokerTest.php @@ -81,6 +81,17 @@ public function setUp(): void $this->mockEventNormalizer = $this->getMockBuilder(EventNormalizer::class)->disableOriginalConstructor()->getMock(); } + /** + * @test + */ + public function withMaximumSequenceNumberRejectsSequenceNumbersSmallerThanZero(): void + { + $this->eventListenerInvoker = new EventListenerInvoker($this->mockEventStore, $this->mockEventListener, $this->mockConnection); + + $this->expectExceptionCode(1597821711); + $this->eventListenerInvoker->withMaximumSequenceNumber(-1); + } + /** * @test * @throws @@ -146,6 +157,21 @@ public function catchUpPassesRespectsStreamAwareEventListenerInterface(): void $this->eventListenerInvoker->catchUp(); } + /** + * @test + * @throws + */ + public function replaySetsHighestAppliedSequenceNumberToMinusOneAndCallsCatchup(): void + { + $this->mockAppliedEventsStorage->expects($this->once())->method('saveHighestAppliedSequenceNumber')->with(...-1); + + $eventListenerInvokerPartialMock = $this->createPartialMock(EventListenerInvoker::class, ['catchUp']); + $eventListenerInvokerPartialMock->__construct($this->mockEventStore, $this->mockEventListener, $this->mockConnection); + $eventListenerInvokerPartialMock->expects($this->once())->method('catchUp'); + + $eventListenerInvokerPartialMock->replay(); + } + /** * @param StreamName|null $streamName * @return EventListenerInterface