function commandByDefault()
 {
     $this->application(GenericAggregateFactory::genericRoot(function ($command) {
         $this->assert->equals($command, 'foo');
     }))->handle('foo');
 }
Exemple #2
0
 /**
  * @param EventStore $store
  * @param AggregateFactory|null $aggregates
  * @param ProjectionFactory|null $projections
  */
 public function __construct(EventStore $store, AggregateFactory $aggregates = null, ProjectionFactory $projections = null)
 {
     parent::__construct($store, $aggregates ?: GenericAggregateFactory::genericRoot(), $projections ?: GenericProjectionFactory::genericProjection());
 }
Exemple #3
0
 private function genericHandler($aggregateRoot)
 {
     return $this->handler(GenericAggregateFactory::staticRoot($aggregateRoot));
 }
Exemple #4
0
 function invokeListeners()
 {
     $heard = [];
     $listenToAll = new CallbackListener(function ($event) use(&$heard) {
         $heard[] = $event;
     });
     $listensToAllButBar = new CallbackListener(function ($event) use(&$heard) {
         $heard[] = $event . ' again';
     }, function ($event) {
         return $event != 'bard';
     });
     $aggregate = Aggregate::genericRoot(function ($command) {
         return $command . 'd';
     });
     $spec = $this->command($aggregate, [$listenToAll, $listensToAllButBar]);
     $spec->given('food');
     $spec->given('bard');
     $spec->when('baz');
     $this->assert->equals($heard, ['food', 'food again', 'bard', 'bazd', 'bazd again']);
 }