Ejemplo n.º 1
0
 public function clear()
 {
     $projections = $this->projectionStorage->find($this->getProjectionName());
     foreach ($projections as $projection) {
         $this->projectionStorage->remove($projection);
         $this->stats->increaseRemoved();
     }
     $this->projectionStorage->flush();
 }
Ejemplo n.º 2
0
 function it_should_run_populator(BulkProjectionStorage $projectionStorage, EventStorage $eventStorage, DomainEventListener $listener)
 {
     $projectionStorage->find('post-list')->willReturn($projections = [new PostListProjection(PostId::generate(), 'Post title', new \DateTime())]);
     foreach ($projections as $projection) {
         $projectionStorage->remove($projection)->shouldBeCalled();
     }
     $projectionStorage->flush()->shouldBeCalled();
     $eventStorage->getAll()->willReturn($events = [new PostWasPublished(PostId::generate(), 'title', 'content', new \DateTime())]);
     foreach ($events as $event) {
         $eventClass = explode('\\', get_class($event));
         $method = 'on' . end($eventClass);
         if (method_exists($listener, $method)) {
             $listener->when($event)->shouldBeCalled();
         }
     }
     $projectionStorage->flush()->shouldBeCalled();
     $this->run();
 }