public function testGetEventsForAggregateWillReturnEvents() { $id = Uuid::createNew(); $eventBus = $this->getEventBus(); $storage = $this->getStorage(); $serializer = $this->getSerializer(); $classMap = $this->getEventClassMap(); $event = new BookAdded($id, [], 'foo', 'bar'); $classMap->expects(self::any())->method('getClassByEventName')->with($event->getEventName())->will(self::returnValue(get_class($event))); $serializer->expects(self::any())->method('serialize')->will(self::returnValue(json_encode(['id' => $event->getId(), 'title' => $event->getTitle()]))); $serializer->expects(self::any())->method('deserialize')->will(self::returnValue($event)); $eventStructure = EventDescriptor::reconstructFromArray(['identity' => $id->getValue(), 'event' => $event->getEventName(), 'playhead' => $event->getVersion(), 'payload' => $serializer->serialize($event, 'json'), 'recorded' => date('r')]); $storage->expects(self::any())->method('contains')->with($id->getValue())->will(self::returnValue(true)); $storage->expects(self::once())->method('find')->with($id->getValue())->will(self::returnValue([$eventStructure])); $store = new EventStore($eventBus, $storage, $serializer, $classMap); $events = $store->getEventsForAggregate($id); self::assertInstanceOf(Events::class, $events); self::assertCount(1, $events->getIterator()); }