/** * @test */ public function it_handles_rebuilding_projections() { $stream = $this->prophesize(EventStreamInterface::class); $this->eventStore->loadAll()->willReturn($stream); $this->projectionManager->clear()->shouldBeCalled(); $this->projectionManager->notify($stream)->shouldBeCalled(); $this->command->handle($this->projectionManager->reveal(), $this->eventStore->reveal()); }
/** * @test */ public function it_clears_projection() { $eventStream = new EventStream(new PointsWereAdded(100)); $this->assertEquals(0, $this->projection->getPoints()); $this->projectionManager->registerProjection($this->projection); $this->projectionManager->notify($eventStream); $this->assertEquals(100, $this->projection->getPoints()); $this->projectionManager->clear(); $this->assertEquals(0, $this->projection->getPoints()); }
/** * @param ProjectionManager $projectionManager * @param EventStoreInterface $eventStore * @return void */ public function handle(ProjectionManager $projectionManager, EventStoreInterface $eventStore) { $eventStream = $eventStore->loadAll(); $projectionManager->clear(); $projectionManager->notify($eventStream); }
/** * @param User $user * @return void */ public function save(User $user) { $recordedEvents = $user->getRecordedEvents(); $this->eventStore->append($recordedEvents); $this->projectionManager->notify($recordedEvents); }